从Socket.IO和更改目录中删除端口

时间:2022-12-07 18:13:49

Using Apache on Ubuntu 15.04 I'm trying to effectively remove the port 3000 from the URL as well as to change the path to http://example.com/{app}/socket.io...

在Ubuntu 15.04上使用Apache我试图从URL中有效地删除端口3000,并将路径更改为http://example.com/ {app} /socket.io ...

Using ProxyPass and ProxyPassReverse I've removed the port from the URL effectively as well as to update the server and client side accordingly to change the path.

使用ProxyPass和ProxyPassReverse我已经有效地从URL中删除了端口,并相应地更新了服务器和客户端以更改路径。

Virtual Hosts changes:

虚拟主机更改:

ProxyPass /path/ http://example.com:3000/path/
ProxyPassReverse /path/ http://example.com:3000/path/

The server side changes that I made was the following:

我所做的服务器端更改如下:

var io = require('socket.io')(http, {path: '/path/socket.io' });
app.get('/path/', function(req, res){

and the client changes that I made was the following:

我所做的客户端更改如下:

var socket = io({path: '/path/'});

Everything appeared to run smoothly until I opened up my console log and saw a plethora of GET requests while using chrome. This'll definitely kill my bandwith and I guess I somehow managed to not listen to the socket correctly which resulted in the mass amount of GET requests.

一切似乎运行顺利,直到我打开我的控制台日志,并在使用chrome时看到了大量的GET请求。这肯定会杀死我的带宽,我想我设法不能正确地听套接字导致大量的GET请求。

Could someone provide some guidance into what I may possibly be doing wrong?

有人能为我可能做错的事情提供一些指导吗?

1 个解决方案

#1


0  

You're seeing a large number of requests as socket.io is falling back to long polling as Apache is not proxying the websocket connection you'll need to enable this with

你看到了大量的请求,因为socket.io正在回退到长轮询,因为Apache没有代理你需要启用它的websocket连接

mod_proxy_wstunnel 

then add

ProxyPass "/path/socker.io"  "ws://localhost:3000/"

#1


0  

You're seeing a large number of requests as socket.io is falling back to long polling as Apache is not proxying the websocket connection you'll need to enable this with

你看到了大量的请求,因为socket.io正在回退到长轮询,因为Apache没有代理你需要启用它的websocket连接

mod_proxy_wstunnel 

then add

ProxyPass "/path/socker.io"  "ws://localhost:3000/"