websockets help :/ - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: websockets help :/ (/thread-32399.html) |
websockets help :/ - kimblee - Feb-07-2021 hello everyone, so i've been trying to improve my skill with websockets, i tried to make a listener for chat42.online but no matter what i did i kept getting the same response back. the code : async def main(): uri = "wss://chat42.online/ws" async with websockets.connect(uri=uri) as websocket: msg = await websocket.recv() print(f"{msg}") asyncio.get_event_loop().run_until_complete(main())i also tried to include the headers but nothing changed, i always get the response: b'\x10\x0c' any help - clue is appreciated! RE: websockets help :/ - kimblee - Feb-11-2021 I tried a different website, i send "2probe", i get "3probe" back, then i send "5" and i get no response back.. RE: websockets help :/ - nilamo - Feb-12-2021 I connected to it using wscat (a command line utility to interact with websocket servers), and didn't get any output at all. This might not be a python issue. You might need to send a message before the server will send anything to you. RE: websockets help :/ - kimblee - Feb-15-2021 (Feb-12-2021, 09:32 PM)nilamo Wrote: I connected to it using wscat (a command line utility to interact with websocket servers), and didn't get any output at all. This might not be a python issue. You might need to send a message before the server will send anything to you. hello, i tried a different website, still can't make it to work, i get no response back after sending "5" import asyncio import websockets import re async def main(): uri = f'wss://strangermeetup.com/socket.io/?lang=en&userId=413fcf79-3837-4608-b29d-ace29f84d3fe&client=web&EIO=3&transport=websocket&sid=' async with websockets.connect(uri=uri) as websocket: msg = await websocket.recv() rec_msg = re.findall('sid":"(.*?)"', msg)[0] async with websockets.connect(uri=f'wss://strangermeetup.com/socket.io/?lang=en&userId=413fcf79-3837-4608-b29d-ace29f84d3fe&client=web&EIO=3&transport=websocket&sid=' + rec_msg) as websocket2: await websocket2.send('2probe') print(await websocket2.recv()) await websocket2.send('5') print(await websocket2.recv()) asyncio.get_event_loop().run_until_complete(main()) |