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

Does it conflict with socket.io(2.0.4)? #1460

Closed
8 tasks
gooddaddy opened this issue Nov 24, 2017 · 1 comment
Closed
8 tasks

Does it conflict with socket.io(2.0.4)? #1460

gooddaddy opened this issue Nov 24, 2017 · 1 comment

Comments

@gooddaddy
Copy link

gooddaddy commented Nov 24, 2017

Issue details

Please provide issue details here.

Steps to reproduce/test case

Please provide necessary steps for reproduction of this issue, or better the
reduced test case (without any external dependencies)
.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ ☑️ ]
  • Node [ ☑️ ]
  • Npm [ ☑️ ]

Affected platforms

  • linux
  • windows
  • [☑️ ] OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • [☑️ ] API
  • Gulp
  • Grunt
  • CLI

{Browsersync init code here}

"browser-sync": "^2.18.11",

 const bundler = webpack(webpackConfig);
    const wpMiddleware = webpackDevMiddleware(bundler, {
      publicPath: clientConfig.output.publicPath,
      stats: clientConfig.stats,
    });
    const hotMiddleware = webpackHotMiddleware(bundler.compilers[0]);
    let handleBundleComplete = async () => {
      handleBundleComplete = stats => !stats.stats[1].compilation.errors.length && runServer();

      const server = await runServer();
      const bs = browserSync.create();

      bs.init({
        ...isDebug ? {} : { notify: false, ui: false },

        proxy: {
          target: server.host,
          middleware: [wpMiddleware, hotMiddleware],
          proxyOptions: {
            xfwd: true,
          },
        },
      }, resolve);
    };

    bundler.plugin('done', stats => handleBundleComplete(stats));

nginx config:

   server {
        listen       3003;
        #server_name  192.168.7.114;

    location / {
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_http_version 1.1;
         proxy_pass  	http://192.168.7.114:3001;
    }
}

I'm using express 4.16.2 and socket.io 2.0.4 ,and I did it like this
io.of("/webPush").connected[socketId].emit('scanLogin',"一发中文就断网,啥玩意啊");
then the error is transport close.
if I use io.of("/webPush").connected[socketId].emit('scanLogin',"111");
it work well。

Are there any other settings that need to be set?

@gooddaddy
Copy link
Author

gooddaddy commented Nov 24, 2017

I have solved this problem.The reason for this problem is the configuration of nginx。

Use the following configuration to work properly


   server {
        listen       3003;
        #server_name  192.168.7.114;

    location / {
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_http_version 1.1;
         proxy_pass  	http://192.168.7.114:3001;
    }

   location /socket.io {
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Host $host;
             proxy_http_version 1.1;
             proxy_pass  	http://192.168.7.114:3000;
   }
}

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

No branches or pull requests

1 participant