最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Proxy blocking websockets? How to get round - Stack Overflow

programmeradmin3浏览0评论

I have a websocket server running written in Python, (from ), and when I try to connect to it from my house, it works fine. However, when I try to connect to it from school, where there is a web proxy in place, it fails to connect with the error "undefined".

I believe that it is the proxy that is stopping the connection, but am not sure how to test to see if it definitely is. How can I test this, and if it is the proxy, how can I get round this?

Thanks

I have a websocket server running written in Python, (from https://github./opiate/SimpleWebSocketServer), and when I try to connect to it from my house, it works fine. However, when I try to connect to it from school, where there is a web proxy in place, it fails to connect with the error "undefined".

I believe that it is the proxy that is stopping the connection, but am not sure how to test to see if it definitely is. How can I test this, and if it is the proxy, how can I get round this?

Thanks

Share Improve this question asked Mar 3, 2015 at 8:41 user2370460user2370460 7,82011 gold badges34 silver badges46 bronze badges 1
  • From what I understand the websocket is a GET followed by a upgrade. Proxies will be blocking the upgrade part since they dont know how to handle it. Defining a rule in there to tell it what to do on upgrade request, websockets should work. – hyades Commented Mar 3, 2015 at 8:57
Add a ment  | 

1 Answer 1

Reset to default 15

Many proxy servers replace the headers of HTTP requests with their own. They will remove any headers they don't understand, so when the proxy doesn't support websocket yet it will prevent any websocket handshake from working.

As a workaround you can get a TLS certificate for your website and use https and wss. This encrypts the headers and thus prevents the proxy from messing with them.

By the way: You should support TLS anyway. In todays world you no longer need a good reason to use encryption, you need a good reason not to.

发布评论

评论列表(0)

  1. 暂无评论