Webpacker: wrong port for HMR sockjs-node

Created on 23 Apr 2019  路  6Comments  路  Source: rails/webpacker

Hi!
It's seems that sockjs get rails port instead webpack-dev-server config port (webpacker.yml).

鈹溾攢 @rails/[email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]

webpack.yml (dev-server part):

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: 0.0.0.0
    port: 3036
    public: 0.0.0.0:3036
    hmr: true
    # Inline should be set to true if using HMR
    inline: true
    overlay: true
    disable_host_check: true
    use_local_ip: false
    quiet: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: /node_modules/

got rails error: ActionController::RoutingError (No route matches [GET] "/sockjs-node/info"):
got js console error: [WDS] Disconnected!

It try to connect sockets in 3007 (rails server port) instead 3036.

Capture d鈥櫭ヽran de 2019-04-23 10-29-45

This return "ok" status if i change port manually and resend request.

To be sure, i reran 'rails webpacker:binstubs' and said me identical files...

Where change config to resolve websocket connection crashes?
Thanks

Most helpful comment

What about specifying sockPort?

  dev_server:
    https: false
    host: 0.0.0.0
    port: 3036
    sockPort: 3036

All 6 comments

@amiuhle is right the line https://github.com/webpack/webpack-dev-server/blob/master/client-src/default/index.js#L211
changes your port when using 0.0.0.0 as a host ...
makes it difficult to use this with docker and docker-compose

I saw this merged PR https://github.com/webpack/webpack-dev-server/pull/1792/files but can't get it to work with webpacker. Has anyone had any luck with this? I have webpack-dev-server version 3.3.1

What about specifying sockPort?

  dev_server:
    https: false
    host: 0.0.0.0
    port: 3036
    sockPort: 3036

seems going well with webpack-dev-server 3.5.1

Upgrading to 3.5.1 got it working for me with sockPort thanks @GuillaumeM59

Was this page helpful?
0 / 5 - 0 ratings