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

signalbot.api.ReceiveMessagesError: server rejected WebSocket connection: HTTP 200 #39

Closed
fwarmuth opened this issue Oct 2, 2023 · 2 comments

Comments

@fwarmuth
Copy link

fwarmuth commented Oct 2, 2023

Hey,
I got problems receiving anything from the rest-api server.
Note: i tried to remove personal info from the logs.
Situation:

  • Example code does not work.
  • rest-api server words via curl command, at least sending.

Minimal setup:

        config = {
            "signal_service": signal_service,
            "phone_number": phone_number,
            "storage": None,
            }

        bot = SignalBot(config)

        bot.start()

Logs:

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:tzlocal:/etc/timezone found, contents:

DEBUG:tzlocal:/etc/localtime found
DEBUG:tzlocal:2 found:
WARNING:root:[Bot] Could not initialize Redis. In-memory storage will be used. Restarting will delete the storage!
INFO:apscheduler.scheduler:Scheduler started
DEBUG:apscheduler.scheduler:Looking for jobs to run
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
INFO:root:[Bot] Producer #1 started
INFO:root:[Bot] Consumer #1 started
INFO:root:[Bot] Consumer #2 started
INFO:root:[Bot] Consumer #3 started
DEBUG:websockets.client:= connection is CONNECTING
DEBUG:websockets.client:> GET /v1/receive/+000000000000 HTTP/1.1
DEBUG:websockets.client:> Host: localhost:18080
DEBUG:websockets.client:> Upgrade: websocket
DEBUG:websockets.client:> Connection: Upgrade
DEBUG:websockets.client:> Sec-WebSocket-Key: ?????????????????????
DEBUG:websockets.client:> Sec-WebSocket-Version: 13
DEBUG:websockets.client:> Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
DEBUG:websockets.client:> User-Agent: Python/3.10 websockets/10.4
DEBUG:websockets.client:< HTTP/1.1 200 OK
DEBUG:websockets.client:< Content-Type: text/plain; charset=utf-8
DEBUG:websockets.client:< Date: Mon, 02 Oct 2023 09:00:09 GMT
DEBUG:websockets.client:< Content-Length: 2
DEBUG:websockets.client:! failing connection with code 1006
DEBUG:websockets.client:x half-closing TCP connection
DEBUG:websockets.client:= connection is CLOSED
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-1' coro=<SignalBot._produce_consume_messages() done, defined at RandomPath/.venv/lib/python3.10/site-packages/signalbot/bot.py:219> exception=SignalBotError('Cannot receive messages: server rejected WebSocket connection: HTTP 200')>
Traceback (most recent call last):
  File "RandomPath/.venv/lib/python3.10/site-packages/signalbot/api.py", line 20, in receive
    async with self.connection as websocket:
  File "RandomPath/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 642, in __aenter__
    return await self
  File "RandomPath/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "RandomPath/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 666, in __await_impl__
    await protocol.handshake(
  File "RandomPath/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 332, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 200

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "RandomPath/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 234, in _produce
    async for raw_message in self._signal.receive():
  File "RandomPath/.venv/lib/python3.10/site-packages/signalbot/api.py", line 25, in receive
    raise ReceiveMessagesError(e)
signalbot.api.ReceiveMessagesError: server rejected WebSocket connection: HTTP 200

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "RandomPath/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 226, in _produce_consume_messages
    await asyncio.gather(*producers)
  File "RandomPath/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 249, in _produce
    raise SignalBotError(f"Cannot receive messages: {e}")
signalbot.bot.SignalBotError: Cannot receive messages: server rejected WebSocket connection: HTTP 200

The rest-api server gives me this:

[GIN] ---------------- | 200 |  6.429480357s |      172.17.0.1 | GET      "/v1/receive/+000000000000000"

any thoughts?

@filipre
Copy link
Owner

filipre commented Oct 2, 2023

Did you start the rest API in the json-rpc mode?

@fwarmuth
Copy link
Author

fwarmuth commented Oct 3, 2023

Of course not! :D

@fwarmuth fwarmuth closed this as completed Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants