Accessing socket.io server via Apache served pages

前端 未结 2 1878
甜味超标
甜味超标 2021-01-17 18:14

I hope this doesn\'t come across as a terribly silly question, but I\'m learning how to implement a socket.io server for my website to produce real-time applications, but my

2条回答
  •  耶瑟儿~
    2021-01-17 18:33

    Socket.io has multiple transport mechanisms. Some of them don't work if you run Apache as reverse proxy, but some do. Transports that don't work are websocket and flash, but xhr-polling and jsonp-polling should work.

    Here's an example on setting the transports configuration option for socket.io:

    var io = require("socket.io").listen(server);
    io.set("transports", ["xhr-polling", "jsonp-polling"]);
    

    On my Apache I'm using the normal name based virtual hosts and reverse proxy setup and with these transports the socket.io seems to be working.

提交回复
热议问题