昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期三, 五月 29, 2019

websocket namespace issue behind apahce reverse proxy

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.




没有评论:

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.