'Socket connection issue, 400 Bad Request
I'm trying to read data sent by a websocket. I can connect to websocket in Postman, but when I try to do it in python, it doesn't work. Error: Handshake status 400 Bad Request. Website: https://tempmail.ninja. Please tell me how can I fix this error.
from websocket import create_connection
headers = {
'Host': 'websocket.solucioneswc.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0',
'Accept': '*/*',
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate, br',
'Sec-WebSocket-Version': '13',
'Origin': 'https://tempmail.ninja',
'Sec-WebSocket-Extensions': 'permessage-deflate',
'Connection': 'keep-alive, Upgrade',
'Sec-Fetch-Dest': 'websocket',
'Sec-Fetch-Mode': 'websocket',
'Sec-Fetch-Site': 'cross-site',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
'Upgrade': 'websocket',
}
url = 'wss://websocket.solucioneswc.com/socket.io/?EIO=3&transport=websocket'
ws = create_connection(url,header=headers)
response = ws.recv()
print(response)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


