-
Notifications
You must be signed in to change notification settings - Fork 83
Problem with Enforcing WebSocket Host and Server Host Match #56
Comments
On Windows 10, I am unable to directly connect to the address Even if this is only a problem on Windows machines, maybe it is still worth making the requirements less strict on that rule? If that check was changed to make room for this case, then it would work as expected. The problem is only that the library is checking if the hosts match instead of trusting the developer. 🙂 |
There's a lengthy discussion on |
Would it not be more user friendly to add a special exception for those who cannot use Webpack-serve is only listening to sockets that originate from I don't think I can fix that unless I use a reverse-proxy inside the container to capture requests and then pass them on to the local instance of webpack-serve. That seems like a lot of extra steps just for a tool that's meant to be used in development. Would you reconsider, please? |
More user-friendly for the very few people who need that capability, yes. More technical debt and maintenance for the project, also yes. You have an edge case. You'll have to find a way to make it work in your specific environment since your environment behaves in a way that doesn't match spec.
That's not actually true.
No, sorry. There are reasonable workarounds, and alternatives (like old crusty |
Using Docker containers in development to ensure that the environment is as close to production as possible doesn't seem to be that uncommon. I don't believe that my environment is wonky; it's just plain old Windows 10. I haven't changed anything in my network settings. The reason I came to this project was because the webpack-dev-server repository has a notice that says that this project is a fast alternative because that project is not receiving feature updates. Could you shed a little light on why the If it's just related to the output, perhaps changing the error to a warning could enable even more use cases that are beyond just this. If a developer wants to change the settings and knows what they are doing, why not let them? |
If the More power to the developer is always great. 😄 |
I'll leave this issue open for discussion for a while in the event other users would like to talk about how to solve this on the user-side of things. You asked me if I would reconsider that change and I gave my answer. At this point more comments aren't going to change that direction. Glad you found this project useful, but it seems you need more customization that the project can provide at this point, and should probably pursue an alternative like |
@shellscape Thanks for your nice job here. Our team is facing similar problems. We are developing a mobile web app based on a Chinese application platform called Wechat. It's used very widely in China. But services based on it have to use the https protocol on the Internet for secure. We coding on Windows 10 and using mobile phones to debug our pages in company's internal network. But we also need to visit the pages from Internet through ngrok which forwarding public URL to localhost server. We add entry But now we will see:
|
hot.host
needing to match host
hot.host
needs to match host
To work within docker, you must expose the WebSocket Server port (8081). For example, my docker-compose.yml:
I think that will solve your problem, although the hot reloading does not work because of this issue: webpack-contrib/webpack-hot-client#26 |
The problem is because the outputted JS tries to connect to the bind address, but this doesn't work because the network inside the container isn't the same as on the host machine. The correct ports are exposed, that's not the problem. Inside the container, we bind on 0.0.0.0 so that the HTTP server can accept connections from outside the container. But the code in the browser on the host machine still tries to connect to that exact address ( |
See:
|
^ Yeah, it's important to keep the general application of this issue in mind. Even if I could connect to
This is a small change that would vastly expand the flexibility of the project. It's a shame that @shellscape won't hear us out. |
Then it is a problem with your environment and I understand that @shellscape is not going to do anything. If you think it's a small change, you should create a pull request. Although I think it will be better if you configure your environment correctly. |
This is not a problem with anyone's environment. This is a limitation of this project. I don't see what all the fuss about; letting the developer control their development tool to fit their needs seems like a no-brainer. Right now, this project is making assumptions about where to connect; what is proposed just allows the developer to specify if they wish. I'm not going to spend my time acquainting myself with a code base I'm completely unfamiliar with and creating a pull request if it's just going to get declined. |
@evaera you might find the legacy |
hot.host
needs to match host
Alright, I give up. I don't understand the reason behind not letting the developer control this when there are valid use cases and people who want this functionality popping up in just a few days, probably more people who didn't even think to check the issues section, but I don't think the community can convince the managers otherwise, so I'm just going to close this issue and try to find another solution that is more accommodating to its developers. |
I also would like to see this feature. Developing on a Mac with |
@nmschulte I tried passing a
but webpack-serve doesn't honor my port config option.
|
@jonesnc I'm seeing that too, I think you should open a new issue for that though |
This must be a |
@evaera @nmschulte I created a new issue regarding this behavior: #89. If you could add any details you have found, I would really appreciate it! |
@jonesnc the issue seems to be resolved with this #34. I use {
"name": "app",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "LOCAL_IP=`hostname -i` webpack-serve --config ./webpack.config.js --mode 'development'",
...
},
"devDependencies": {
...
"webpack-serve": "^0.3.1"
},
...
}
with the following module.exports = {
...
serve: {
host: '0.0.0.0',
hot: {
host: {
server: '0.0.0.0',
client: process.env.LOCAL_IP
}
}
},
...
} And it works! |
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
* Cope with errors about websocket connection using Docker container * see also: webpack-contrib/webpack-serve#56 (comment)
This issue is for a:
Code
CLI Command
$ webpack-serve
webpack.config.js
Expected Behavior
When run from a Docker container, webpack-serve must be bound on
0.0.0.0
in order for the server to be accessible atlocalhost
on the parent machine. However, hot-client must be set to hostlocalhost
in order for the container to receive the connection.Actual Behavior
When the hot.host option is omitted, hot-client attempts to connect to an invalid address.
How Do We Reproduce?
New Feature Use Case
The ability to configure where the emitted bundle tries to connect via WebSocket will enable many use cases beyond just Docker. Since this is a tool for development, it's important to be flexible and not disrupt workflow with needless red tape when this could just be a base option.
The text was updated successfully, but these errors were encountered: