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

[WDS] Disconnected! with option set to HTTPS #574

Closed
pungggi opened this issue Sep 4, 2016 · 14 comments
Closed

[WDS] Disconnected! with option set to HTTPS #574

pungggi opened this issue Sep 4, 2016 · 14 comments

Comments

@pungggi
Copy link

pungggi commented Sep 4, 2016

I am using the new HTTPS option to test locally from https browser to https server.
the comunication between client and server works but i get an error in the browser console>

abstract-xhr.js:132 GET https://localhost/sockjs-node/info?t=1472999253306 net::ERR_CONNECTION_REFUSEDAbstractXHRObject._start @ abstract-xhr.js:132(anonymous function) @ abstract-xhr.js:21
client:70 [WDS] Disconnected!sock.onclose @ client:70EventTarget.dispatchEvent @ eventtarget.js:51(anonymous function) @ main.js:356

image

HMR not working.

@gaearon
Copy link
Contributor

gaearon commented Sep 4, 2016

@dceddia Can I ask you to investigate this?

@dceddia
Copy link
Contributor

dceddia commented Sep 4, 2016

@gaearon Taking a look...

I can reproduce it locally against 0.4.1. However, I don't see this error with 0.3.0-alpha (which is where I originally tried out this HTTPS feature and used it successfully for a couple weeks). Maybe something changed with the how socket connection works?

Edit: The difference has something to do with how that URL is determined. On the (old) version that worked, the url has the port specified, e.g. https://localhost:3000/sockjs-node/... whereas the broken one leaves out the port like https://localhost/sockjs-node/....

Maybe it's a webpack change - the broken one is running webpack-dev-server 1.15.1 while the working one is using 1.14.1...

Edit 2: Confirmed that it works with 1.14.1 but doesn't work with 1.15.1. Looking into why...

@dceddia
Copy link
Contributor

dceddia commented Sep 4, 2016

It looks like it has something to do with how the webpack-dev-server client determines the URL. In v1.15.1:

https://github.com/webpack/webpack-dev-server/blob/v1.15.1/client/index.js#L62

protocol: (window.location.protocol === "https:" || urlParts.hostname === '0.0.0.0') ? window.location.protocol : urlParts.protocol,

In v1.14.1:

https://github.com/webpack/webpack-dev-server/blob/v1.14.1/client/index.js#L62

protocol: urlParts.protocol,

Changing that one line to the old protocol: urlParts.protocol fixes this issue. That's not terribly helpful for us though, since there doesn't seem to be any way to influence how that protocol is decided.

@gaearon Sorry for letting this slip through. Would you like me to file an issue with webpack-dev-server? Can you see another way around it?

@gaearon
Copy link
Contributor

gaearon commented Sep 5, 2016

Please file an issue with WDS. We can release a path that rolls our version of it back if this takes time to fix.

@chall8908
Copy link

chall8908 commented Sep 6, 2016

Per my comment on #263 (sorry for misposting that), I've fixed this locally by changing this line in config/webpack.config.dev.js:
require.resolve('webpack-dev-server/client') + '?/',
to
require.resolve('webpack-dev-server/client') + '?http:https://0.0.0.0:0/',

Based on my understanding of the WDS code, this will configure the client to use the current window's protocol, hostname, and port.

A point of interest is that I was not seeing the initial connection going through at all until I made this change. Though, afterwords, everything is working correctly.

EDIT: To clarify, by "fixed locally" I modified the config file without ejecting first. Not good practice, but I was just trying to see if I could fix it.

@dceddia
Copy link
Contributor

dceddia commented Sep 6, 2016

Nice, that fixes it for me too.

I was worried that it might break hostnames other than localhost, so I tried giving my machine an alias of devtest in /etc/hosts -- everything seems to work fine. Also tested with 127.0.0.1. I can't think of any other negative side-effects this change would have, besides it feeling like a hacky workaround for a WDS bug.

I could make a PR if we want to get the fix in though, thoughts?

@gaearon
Copy link
Contributor

gaearon commented Sep 6, 2016

It was 0.0.0.0 at some point but I changed it because something else broke. I don't recall what though.

@dceddia
Copy link
Contributor

dceddia commented Sep 13, 2016

It looks like Webpack won't get this fix until v2 unfortunately, so maybe
we should roll back to 1.14.1 for the time being, if that's an option:
webpack/webpack-dev-server#592 (comment)

On Tuesday, September 6, 2016, Dan Abramov [email protected] wrote:

It was 0.0.0.0 at some point but I changed it because something else
broke. I don't recall what though.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#574 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAe3aGNsHbhkzJM6U6Et6qJUpZTo4nIEks5qnagTgaJpZM4J0jGM
.

@gaearon
Copy link
Contributor

gaearon commented Sep 13, 2016

@dceddia Send a PR please?

@SpaceK33z
Copy link
Contributor

Hi, webpack-dev-server maintainer here. Reverting to 1.14.1 would probably cause other issues to come up again (e.g. #134), so would probably not be worth it.

I've changed my mind about this a bit, since I don't know when v2 will get stable, and this seems to be a blocking issue for some people.

If someone wants to backport the fix to v1, I'll merge the PR and release a new version. Don't have time to do it myself currently.

PS: also said this in the ticket mentioned above, but saying it here for visibility 😄.

@SpaceK33z
Copy link
Contributor

I just released [email protected] with the fix for this. Thanks for the help @dceddia.

dceddia added a commit to dceddia/create-react-app that referenced this issue Sep 14, 2016
@dceddia
Copy link
Contributor

dceddia commented Sep 14, 2016

Awesome, thanks @SpaceK33z. I just tried it out - it seems to fix this issue :)

@gaearon I created a PR to bump the dependency up to 1.15.2.

@gaearon gaearon added this to the 0.4.2 milestone Sep 18, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

This should be fixed in 0.4.2.
Please verify!

@pungggi
Copy link
Author

pungggi commented Sep 18, 2016

Yes it works! Good job.

feiqitian pushed a commit to feiqitian/create-react-app that referenced this issue Oct 25, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants