One of our projects is a websocket microservice. It runs well on the local environment. But after deploying on a azure VM, the client cannot connect to it.
After some investigation, I noticed that the problem was caused by web socket name space.
Because the service itself is behind a Apache proxy, a path is added to the domain similar to
Apache will match the virtualpath and redirect the request to the correct service.
The service is not working because with socket.io, the virtualpath is treated as web socket namespace.
this.socket = io('https://domain.com/virtualpath/'});
But the server is expecting default namespace '/'.
The make this work, we have to rewrite this code as below:
this.socket = io('https://domain.com/', { path: '/virtualpath/socket.io'});
This will tell web socket that the name space is the default one, but there is a virtual path to append to the domain for the websocket service.
没有评论:
发表评论