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

websockets not working when compress = true in toml config. #1059

Closed
JamesKyburz opened this issue Jan 23, 2017 · 2 comments
Closed

websockets not working when compress = true in toml config. #1059

JamesKyburz opened this issue Jan 23, 2017 · 2 comments

Comments

@JamesKyburz
Copy link
Contributor

What version of Traefik are you using (traefik version)?

traefik:v1.1.2-alpine

What is your environment & configuration (arguments, toml...)?

using docker

toml

logLevel = "DEBUG"
debug = true
defaultEntryPoints = ["http", "https"]
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  compress = true
    [entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
      CertFile = "/ssl/cert.pem"
      KeyFile = "/ssl/cert.key"

[docker]
  domain = "local.awesome.jsmentor.se"
  endpoint = "unix:///var/run/docker.sock"
  exposedbydefault = false

docker-compose

version: '2'
services:
  ws:
    networks:
      - awesome
    environment:
      - TZ=Europe/Stockholm
      - PORT=5000
    build:
      context: ./src/ws
    labels:
      - "traefik.enable=true"
      - "traefik.backend=machine-ws"
      - "traefik.frontend.rule=Host:local.awesome.jsmentor.se;PathPrefix:/ws"
      - "traefik.frontend.passHostHeader=true"

  proxy:
    networks:
      - awesome
    environment:
      - TZ=Europe/Stockholm
    command: --web
    image: traefik:v1.1.2-alpine
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./src/proxy/traefik-dev.toml:/traefik.toml
      - ./src/proxy/ssl/dev:/ssl
    labels:
      - "traefik.frontend.rule=Host:local.awesome.jsmentor.se;PathPrefixStrip:/dashboard"
    ports:
      - "80:80"
      - "443:443"
      - "9443:9443"

networks:
  awesome:
    driver: bridge

What did you do?

var ws = new WebSocket('wss://local.awesome.jsmentor.se/ws')

What did you expect to see?

a succesful update and working websocket connection.

What did you see instead?

WebSocket {url: "wss://local.awesome.jsmentor.se/ws", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null…}
VM234:1 WebSocket connection to 'wss://local.awesome.jsmentor.se/ws' failed: Error during WebSocket handshake: Unexpected response code: 500
proxy_1    | time="2017-01-23T16:54:44Z" level=warning msg="Unable to hijack the connection: *negroni.responseWriter the ResponseWriter doesn't support the Hijacker interface"

If I turn compression off in my toml file everything works. But I want compression :)

My guess is that the gzip middleware processes http upgrade which it shouldn't.

I have been unable to verify if this problem persists using the latest code in master.

New to go, would like to submit a PR if a fix is needed, but need some pointers to get me started.

@JamesKyburz
Copy link
Contributor Author

I can confirm the latest master at this moment in time also has this bug.

I ran master with an updated gziphandler

This commit in gziphandler has fixed the issue.

@JamesKyburz JamesKyburz changed the title wss:// websockets not working when compress = true in toml config. websockets not working when compress = true in toml config. Jan 30, 2017
@JamesKyburz
Copy link
Contributor Author

Just removed wss from issue title.

Websockets currently don't work when compression is enabled.

vdemeester added a commit that referenced this issue Feb 4, 2017
@ldez ldez modified the milestone: 1.3 Apr 29, 2017
@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants