View Logs / exec shell - Bad handshake

Greetings,

When trying to view logs or execute shell, I am getting a websocket handshake error.

I am aware of the fact that the clock issue and I have checked multiple times than my clocks are synchronized on every container and the host OS. (the clock issue shouldn’t be causing a 404 anyway, but a 401). I wouldn’t post here I werent completely stumped. Thanks for any help in advance

My OS:
Ubuntu 14.04.4 LTS (4.2.0-42-generic)

Docker:
Docker version 1.12.0, build 8eab29e

The error itself in the rancher-agent container

time=“2016-08-11T23:10:46Z” level=“info” msg=“Connecting to proxy.” url="ws://10.0.2.15:8081/v1/connectbackend?token=eyJ
hbGciOiJSUzI1NiJ9.eyJleHAiOjE0NzA5NTczNDYsInN1YiI6ImNhdHRsZSIsImlzcyI6Imh0dHA6XC9cL2NhdHRsZS5pbyIsInJlcG9ydGVkVXVpZCI6Im
QxNzNkMzgxLTY1ZDgtNGY0YS1hMWNmLTBjZmYxNzU1ZTdmYiIsImlhdCI6MTQ3MDk1NzA0Niwia2lkIjoiZGVmYXVsdCJ9.VhD43pgBccEDKOr7Nu9hx2nAe
EZHgjDXOjeVkdFwA1Tdi3rKQ05UylUtMdtLe6lY-hrysjTyU7tVGUr8Hi3MymXRcgnTAfh41mF-eZhmEjuBV-WPZTWrylLoFoD-cZdB_n4bnSZkxU1ADpTM-
9ZD5KIjBG_-UKbbPmE-jLnOEGta1ryduzaK42LNFXnfiqnYZX6SJVaz_iY43wFwKMgmPSkyz0-9VPC1w5FOIZYREYqfsqPPlxmH-idiPPhNRRinuj9yxS5bH
y0CHfcquw72TTxZKfSwvebU5hG0WVwj47dB7flYFUZGsiQu-yQ4NRYqwqxVs5Vp5xRDfWsOpzCkgw"
time=“2016-08-11T23:10:46Z” level=“fatal” msg=“Failed to connect to proxy.” error=“websocket: bad handshake”

Here’s the error from the front end

WebSocket connection to ‘ws://localhost:8081/v1/logs/?token=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0NzA5NTY5MzAsInN1YiI6ImNhdHRsZSIsImxvZ3MiOnsiQ29udGFpbmVyIjoiZTgyNzllMWNkZWRmMDE2ZWY5Yzk0YjFmOWU0NjRlNzE4ZWRlNDc1Y2ZlMmRlNTY1NTljOTc0ZTdkOGNkM2EyNCIsIkxpbmVzIjo1MDAsIkZvbGxvdyI6dHJ1ZX0sImlzcyI6Imh0dHA6XC9cL2NhdHRsZS5pbyIsImhvc3RVdWlkIjoiZDE3M2QzODEtNjVkOC00ZjRhLWExY2YtMGNmZjE3NTVlN2ZiIiwiaWF0IjoxNDcwOTU2NjMwLCJraWQiOiJkZWZhdWx0In0.Yylz_1s9WA34QOM2299aFStBxWuXMSwdTiji5ZNA-hxq-38pnGxbbAng-qEe938G85ZMD3Kf8sF9lsO_liEwzmrZINeb5Q7nWyxThc2P031cCNQQUi2TycpytSPExuoV2VTjSCmjzbDVhPJYnkAIIth71mb1csOvknq_OF5qzH74UWpxMXZsKyRHIO0p8C4IFb2LRx2U7n0vvAVeulzoPA2r2ZauGiWSQTZUL-_B-bJGWR7Yg0Yjh1TzPhiL5onL6Hm2uVBjESJXN1VdcYMeblxUuDohj4VluV_4R01saEWGPKIdMZB4_TwmD3tV7Ly2MA5o5PABSrat0-gJc1063Q’ failed: Error during WebSocket handshake: Unexpected response code: 404

Resolved after reading

I realized that using a nonstandard port (8081) might be the culprit messing up the handshake.

Sure enough changing it to 8080 fixed it. I had another service running on 8080 so I didn’t want to do this :slight_smile: might want to update the documentation to warn about not using 80/8080 for rancher server.

Do you have a load balancer, ssl termination, proxy, or similar in between the client and server? There’s nothing special about 8080…

1 Like

Well, ‘Launching Rancher Server’ recommends a port so I wasn’t sure.

This is all locally for development so nothing exotic. I’m running the Ubuntu host through vagrant (starting with the image williamyeh/ubuntu-trusty64-docker to be specific). Unless I’m missing something I don’t think any of those would apply.

I had the same issue,and switch to 8080 ,the rancher server and other host worked fine.There’s something special about 8080 indeed @vincent

1 Like

same issue logs showing

msg=“Connecting to proxy.” url="ws://xx.yy.zz.aa:12345/v1/connectbackend?token=…
level=“fatal” msg=“Failed to connect to proxy.” error=“websocket: bad handshake”

tried changing the port from 12345 to 8888 to see if that would help same error msg… “websocket: bad handshake”

changed from 8888 to 8080 started working fine was able to login into shell and look at logs. really something special about 8080 as stated by Mr_Koo

There is nothing special about 8080. A significant fraction of installations change it, usually to 80/443.