Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Stream through http library not functioning when hostname in server.listen function supplied #6541

Closed
rianadon opened this issue May 3, 2016 · 9 comments
Labels
net Issues and PRs related to the net subsystem. question Issues that look for answers. windows Issues and PRs related to the Windows platform.

Comments

@rianadon
Copy link

rianadon commented May 3, 2016

  • Version: v6.0.0
  • Platform: Windows 10 (x64), build 14332
  • Subsystem: http

First of all, this is coming from this issue if you need any more details.

I am currently running Windows Insider build 14322, and am encountering problems when trying to create an Event Stream through the HTTP module.

I downloaded the Node.js code and HTML file from this HTML5 Rocks tutorial, and the example works as it should.

However, If I change the .listen(8000); after the http.createServer call to .listen(8000, 'localhost'); or .listen(8000, '0.0.0.0');, the Event Stream to stop functioning and display as "pending" in the Chrome Dev tools rather than complete.

I wrote a small program to simulate an HTTP request to the Event Source, and the HTTP request yields the same data but with different values for the Date header and data.

@addaleax
Copy link
Member

addaleax commented May 3, 2016

Not sure I fully understand what’s going on, but something you should be aware of is that .listen(port) is different from .listen(port, '0.0.0.0') in the way it handles IPv6:

If the hostname is omitted, the server will accept connections on any IPv6 address (::) when IPv6 is available, or any IPv4 address (0.0.0.0) otherwise.

(from https://nodejs.org/api/net.html#net_server_listen_port_hostname_backlog_callback)

@addaleax addaleax added question Issues that look for answers. net Issues and PRs related to the net subsystem. labels May 3, 2016
@rianadon
Copy link
Author

rianadon commented May 3, 2016

Thank you for getting back to me.

I am basically just trying to get the code at this gist to work.

When I don't specify the hostname in the .listen function, the example works perfectly. However, changing it to any valid, non-null value (whether that be ::, 0.0.0.0, localhost, or 127.0.0.1), the Event Stream hangs in Chrome and Firefox.

Also, this seems to only happen in this Insider build of Windows (the example works when specifying the hostname on another computer running the latest non-Insider version of Windows 10).

@bnoordhuis
Copy link
Member

That suggests an issue with your Windows build or configuration. There's probably not much we can do about that.

@addaleax
Copy link
Member

addaleax commented May 3, 2016

What does void require('dns').lookup('localhost', console.log) (from e.g. the repl) do for you? Does it work, i.e. print something like null '127.0.0.1' 4? afaik the only difference between .listen() with a hostname argument and without it is an extra call to dns.lookup.

@addaleax addaleax added the windows Issues and PRs related to the Windows platform. label May 3, 2016
@rianadon
Copy link
Author

rianadon commented May 4, 2016

Yep. It returns null '127.0.0.1' 4. I forgot to mention this, but what's especially intriguing is that the program in the gist serves index.html correctly. It's just the Event Stream that doesn't work.

Also, the eventsource library is able to download the event stream, but not Chrome or Firefox.

@rianadon
Copy link
Author

rianadon commented May 4, 2016

This might actually be a problem with Windows. When using .listen(8000, '0.0.0.0');, using Chrome and Firefox on that same computer don't work, but using Chrome or Firefox on another computer running the latest non-Insider build of Windows loads the event stream.

Also, using .listen(8000) works only in Chrome on the same computer, but works in both Firefox and Chrome on the other.

@rianadon
Copy link
Author

rianadon commented May 5, 2016

I tried running the same program on the laptop with a non-Insider build of Windows and accessing the sever from the laptop with build 14332 and the event stream doesn't work regardless of whether I supply a hostname argument or not to .listen.

Also, when I stop the program, the messages sent through the event stream are transferred correctly.

@bnoordhuis
Copy link
Member

Do I understand correctly that your conclusion is that it's a problem with the Insider build? Can I suggest you close this issue in that case?

@rianadon
Copy link
Author

rianadon commented May 6, 2016

I'm not exactly sure; that's why I've kept this open. As it seems as if there are no differences between .listen with and without a hostname that would cause this, I guess I'll close this issue and reopen it if this persists in later Insider builds or I find anything suggesting this is related to node.js.

Thank you for trying to help!

@rianadon rianadon closed this as completed May 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. question Issues that look for answers. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

3 participants