项目在测试环境可以正常使用websockect,然而把项目发布到公网上却无法使用问题。

有几种解决方案,1、防火墙未加入入站规则,否则没有权限连接到外网。

        方法:控制面板--window防火墙---高级设置---入站规则---右侧新建入站规则--在特定本地端口中输入新增端口---下一步---名称中输入该端口的备注---完成。。

 

 

       2.、如果用到Nginx需要做以下修改 

 

     location ~/WSPush

       { proxy_pass http://ws; proxy_http_version 1.1;

         proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "upgrade";

         proxy_set_header Host $host:$server_port; #这个用来透传用户http请求头的,因为我代码里调用了request.getServerName()方法,如果不加个配置,取出来是http://ws         proxy_read_timeout 30m;#这里一定不要忘了改,默认1分钟后nginx会断开ws }

 

     具体api网址 http://nginx.org/en/docs/http/websocket.html

 

 

 

 

相关文章:

  • 2021-05-20
  • 2021-09-15
  • 2021-12-12
  • 2021-05-28
  • 2021-10-30
  • 2021-09-15
  • 2021-06-28
  • 2021-11-16
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2021-07-31
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案