question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Server Sent Events

See original GitHub issue

Does the new LWS support eventsource connections to backend services? The previous version was working fine. On version

$ ws --version
2.0.0-pre.4

eventsource (aka Server Sent Events with accept: 'text/event-stream',) seem to always return empty responses. When using -v to see the output, the data field is empty (see all the way at the end)…

{ 'socket-data': { id: 5, bytesRead: 730, bytesWritten: 0 } }
{ 'rewrite-proxy-req':
   { req:
      Url {
        protocol: 'http:',
        slashes: true,
        auth: null,
        host: '**myhostname**:8080',
        port: '8080',
        hostname: '**myhostname**',
        hash: null,
        search: '?&streamId=13d783492c76a9be5fbb34bdaeb936c9691fd893fd67a11ed99051c55c855259',
        query: '&streamId=13d783492c76a9be5fbb34bdaeb936c9691fd893fd67a11ed99051c55c855259',
        pathname: '/path/to/stream',
        path: '/path/to/stream?&streamId=13d783492c76a9be5fbb34bdaeb936c9691fd893fd67a11ed99051c55c855259',
        href: 'http://**myhostname**:8080/path/to/stream?&streamId=13d783492c76a9be5fbb34bdaeb936c9691fd893fd67a11ed99051c55c855259',
        id: 3,
        method: 'GET',
        headers:
         { host: '**myhostname**:8080',
           connection: 'keep-alive',
           accept: 'text/event-stream',
           'cache-control': 'no-cache',
           'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36',
           dnt: '1',
           referer: 'http://**myhostname**/path/to/app/',
           'accept-encoding': 'gzip, deflate',
           'accept-language': 'en-US,en;q=0.8',
           cookie: 'JSESSIONID=15A2;and_other_cookies..' },
        rejectUnauthorized: false },
     data: '' } }

See the last line has empty data: data: ''. But when I hit my downstream service directly I get periodic events as expected. Is there a new middleware I need to configure/enable to turn on SSE for rewrite requests?

I haven’t tried websockets so it may or may not behave the same way.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
djKianooshcommented, Jun 29, 2017

Fantastic. Works great… now -v verbose output shows:

        statusCode: 200,
        statusMessage: 'OK',
        url: '' },
     data: [ SSE event-stream ] } }

👍

1reaction
75lbcommented, Jun 29, 2017

this is fixed in v2.0.0-pre2.4, please reinstall

npm install -g local-web-server@next

thanks again, let me know if you find anything else!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-sent events | Can I use... Support tables for ... - CanIUse
Server -sent events · Global · Chrome · Edge * · Safari · Firefox · Opera · IE · Chrome for Android.
Read more >
Using server-sent events - Web APIs | MDN
The server-side script that sends events needs to respond using the MIME type text/event-stream . Each notification is sent as a block of...
Read more >
HTML SSE API - Server-Sent Events - W3Schools
A server-sent event is when a web page automatically gets updates from a server. This was also possible before, but the web page...
Read more >
Server-sent events - Wikipedia
Server -Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via an HTTP connection,...
Read more >
Announcing support for Server-Sent Events (SSE) | Ably Blog
SSE is commonly used to send message updates, new events, or continuous data streams to a browser client. It's designed to enhance native,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found