Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket 报错 #165

Closed
snecker opened this issue Mar 8, 2017 · 10 comments
Closed

websocket 报错 #165

snecker opened this issue Mar 8, 2017 · 10 comments
Labels

Comments

@snecker
Copy link

snecker commented Mar 8, 2017

报错 Uncaught Error: Incompatibile SockJS! Main site uses: "1.0.3", the iframe: "1.0.1".

经搜索,发现是版本问题, facebook/create-react-app#1268

请问如何解决

@sorrycc
Copy link
Owner

sorrycc commented Mar 9, 2017

怎么重现?安装最新版的 roadhog 然后 roadhog server ?

@snecker
Copy link
Author

snecker commented Mar 9, 2017

是的,最新版本的roadhog

@wangyazhen
Copy link

我用nginx做了反向代理 为的是配置一个域名 然后就是出现了这个问题
bug

@wangyazhen
Copy link

我的问题已经解决了

@sorrycc sorrycc closed this as completed Mar 16, 2017
@YueHui
Copy link

YueHui commented Sep 6, 2017

能分享下是怎么解决的吗

@houming818
Copy link

@wangyazhen 你的问题就是我的问题.你怎么解决的?

@YueHui
Copy link

YueHui commented Nov 14, 2017

@stduolc 可以配下nginx 的websocket 不知道对你有没有帮助:

location /sockjs-node{
                proxy_pass http://127.0.0.1:8989;  #你的服务地址
                proxy_redirect off;
                #proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                break;
        }

@wangyazhen
Copy link

@stduolc 我不是很清楚其中原理 大概猜测是域名问题 我在.roadhogrc 中配置了proxy

"proxy": {
    "/api": {
      "target": "http://domain.com/",
      "changeOrigin": true,
      "pathRewrite": { "^/api" : "/api" }
    }
  }

@sorrycc 有时间的话不知道能否简单描述一下原理大概是什么样的 非常感谢

@YueHui
Copy link

YueHui commented Nov 15, 2017

说下我的理解,
热更新从原来的ajax 方式换成了websocket,但socket域名应该是直接读的location.hostname,我本地开发又是配的nginx,所以websocket请求路径的时候就404了,上面的配置是让nginx支持websocket,转发到webpack的开发服务器。

@dbwcooper
Copy link

@YueHui 非常感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants