1

I use socket.io 2.1.1 in my mean-stack website by AngularJS.

The website works well when we call it by IP: https://47.52.108.146/1/#/edit/

Then, I added a CDN (https://www-source.qiniu.com/en) on top of it. However, the console of https://www.funfun.ink/1/#/edit/ repeatedly showed errors:

GET https://www.funfun.ink/pathSocketIO/?EIO=3&transport=polling&t=MHOgXNw&sid=CIzEAy8ZnhMciGuOAAAf 400 () 
POST https://www.funfun.ink/pathSocketIO/?EIO=3&transport=polling&t=MHOgcU6&sid=CIzEAy8ZnhMciGuOAAAf 400 ()
WebSocket connection to 'wss://www.funfun.ink/pathSocketIO/?EIO=3&transport=websocket&sid=4Z1-Nc7ElaAA22X9AAAg' failed: Error during WebSocket handshake: Unexpected response code: 400

I tried to add a rule in the CDN to not cache anything in /pathSocketIO, but it did not help.

Does anyone know how to fix this?

enter image description here

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • Well, whatever is receiving your socket.io connection URL is returning a 400 status. So, it appears that whatever you did for your CDN configuration is not allowing that request to get through to your server. You don't show any of the relevant configuration that caused the problem or even tell us what technology you are using for that so I don't see how we'd have any idea how to help. The answer is fix your CDN so it passes the socket.io connection request through to your server. Also, do you really mean "CDN" or do you mean "proxy"? – jfriend00 Jul 02 '18 at 04:15
  • I use a real CDN provider https://www-source.qiniu.com/en, the problem is that it is like a blackbox, the support is not great... – SoftTimur Jul 02 '18 at 09:16
  • Well, you could put your socket.io server on a different host and enable CORS and not have the CDN configured at all for that host. – jfriend00 Jul 02 '18 at 14:26
  • This is what I wanted to do... But I have a problem with CORS, do you have any idea? https://stackoverflow.com/questions/51132558/403-and-404-errors-when-setting-up-a-server-serving-static-files – SoftTimur Jul 02 '18 at 15:31
  • You'd have to show what you tried to do to enable CORS. A couple of ways of configuring it are here: [Socket.io cross origina request blocked](https://stackoverflow.com/questions/24058157/socket-io-node-js-cross-origin-request-blocked). And, then you'd need a different domain that doesn't route to the CDN. – jfriend00 Jul 02 '18 at 15:52
  • I don't see what that other question you previously referenced has to do with anything. That's a question related to an nginx proxy configuration which you did not say you were using. I'm thoroughly confused now. – jfriend00 Jul 02 '18 at 15:53

0 Answers0