代理自己的socket.io服务器时如何使Webpack热模块替换(react-hot-loader)工作

Nic*_*rum 5 socket.io webpack webpack-hmr

我有一个正在使用socket.io的节点快速应用程序。该应用程序通过webpack的开发服务器代理,因为我想在客户端react应用程序中使用热模块替换(该模块可通信回节点应用程序上的套接字代码。)

socket.io但是,如果我添加了侦听器,则会破坏热模块更换的内容。我猜是因为我的监听器正在接收消息而不是hmr监听器?

问题是,当我保存将被热加载的文件时,我在chrome开发工具中获得了以下内容,并且没有热加载:

[WDS] App updated. Recompiling...
client?eeaa:52 [WDS] Proxy error.
client?eeaa:54 cannot proxy to http://127.0.0.1:1338 (read ECONNRESET)
client?eeaa:90 [WDS] App hot update...
socket.io.js:1456 GET http://localhost:1339/socket.io/?EIO=3&transport=polling&t=LA7JXr9&sid=r1NFzh1HOD5GcbN0AAAA 502 (Bad Gateway)
client?eeaa:25 [WDS] App updated. Recompiling...
client?eeaa:90 [WDS] App hot update...
socket.io.js:1456 POST http://localhost:1339/socket.io/?EIO=3&transport=polling&t=LA7Jckl&sid=r1NFzh1HOD5GcbN0AAAA 400 (Bad Request)
Run Code Online (Sandbox Code Playgroud)

(的主体400 (Bad Request)为:

{"code":1,"message":"Session ID unknown"}
Run Code Online (Sandbox Code Playgroud)

有人知道如何正确设置吗?

webpack.config.js当前是:

var path    = require('path');
var webpack = require('webpack');

module.exports = {
  entry:  [
    'webpack-dev-server/client?http://127.0.0.1:1339/',
    'webpack/hot/only-dev-server',
    './src/client/main.js'
  ],
  output: {
    path:     path.join(__dirname, 'dist'),
    filename: 'client-bundle.js'
  },
  resolve: {
    modulesDirectories: ['node_modules'],
    extensions:         ['', '.js']
  },
  module: {
    loaders: [
      {
        test:    /\.js$/,
        exclude: /node_modules/,
        loaders: ['react-hot', 'babel']
      }, {
          test: /\.css$/,
          loader: 'style!css'
      }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  devtool: 'inline-source-map',
  devServer: {
    hot: true,
    proxy: {
      '*': 'http://127.0.0.1:' + (process.env.PORT || 1338)
    },
    host: '127.0.0.1'
  }
};
Run Code Online (Sandbox Code Playgroud)