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

Cannot run readme - Connect call failed ('127.0.0.1', 80) #56

Closed
jaanli opened this issue May 12, 2024 · 2 comments
Closed

Cannot run readme - Connect call failed ('127.0.0.1', 80) #56

jaanli opened this issue May 12, 2024 · 2 comments

Comments

@jaanli
Copy link
Contributor

jaanli commented May 12, 2024

Steps to reproduce (testing on Ubuntu 22.04.1 LTS on a LightSail AWS server for free):

  1. Install docker:
sudo snap install docker
  1. Fix docker permissions:
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
  1. Test the getting started page of https://github.com/bbernhard/signal-cli-rest-api?tab=readme-ov-file#getting-started:
$ mkdir $HOME/.local/share/signal-api
$ sudo docker run -d --name signal-api --restart=always -p 8080:8080 \
      -v $HOME/.local/share/signal-api:/home/.local/share/signal-cli \
      -e 'MODE=native' bbernhard/signal-cli-rest-api
--> Then register device at http://localhost:8080/v1/qrcodelink?device_name=signal-api
$ curl -X POST -H "Content-Type: application/json" 'http://localhost:8080/v2/send' \
     -d '{"message": "Test via Signal API!", "number": "+4412345", "recipients": [ "+44987654" ]}' 
  1. Go back to this repository and follow the instructions:

Original command:

docker run -p 8080:8080 \
    -v $(PWD)/signal-cli-config:/home/.local/share/signal-cli \
    -e 'MODE=normal' bbernhard/signal-cli-rest-api:0.57

Modified command because the original one yields errors:

docker run -p 8080:8080 \
    -v $HOME/signal-cli-config:/home/.local/share/signal-cli \
    -e 'MODE=normal' bbernhard/signal-cli-rest-api

Then register; then kill the docker container and restart in rpc mode:

Original command:

docker run -p 8080:8080 \
    -v $(PWD)/signal-cli-config:/home/.local/share/signal-cli \
    -e 'MODE=json-rpc' bbernhard/signal-cli-rest-api:0.57

Modified command because the original command breaks:

docker run -p 8080:8080 \
    -v $HOME/signal-cli-config:/home/.local/share/signal-cli \
    -e 'MODE=json-rpc' bbernhard/signal-cli-rest-api

This yields the following logs:

time="2024-05-12T19:13:44Z" level=info msg="Updated jsonrpc2.yml"
+ [ -n  ]
+ service supervisor start
Starting supervisor: supervisord.
+ supervisorctl start all
+ + awk {print $1}
hostname -I
+ export HOST_IP=172.17.0.2
+ exec setpriv --reuid=1000 --regid=1000 --init-groups --inh-caps=-cap_0,-cap_1,-cap_2,-cap_3,-cap_4,-cap_5,-cap_6,-cap_7,-cap_8,-cap_9,-cap_10,-cap_11,-cap_12,-cap_13,-cap_14,-cap_15,-cap_16,-cap_17,-cap_18,-cap_19,-cap_20,-cap_21,-cap_22,-cap_23,-cap_24,-cap_25,-cap_26,-cap_27,-cap_28,-cap_29,-cap_30,-cap_31,-cap_32,-cap_33,-cap_34,-cap_35,-cap_36,-cap_37,-cap_38,-cap_39,-cap_40 signal-cli-rest-api -signal-cli-config=/home/.local/share/signal-cli
time="2024-05-12T19:13:46Z" level=info msg="Started Signal Messenger REST API"

Then clone the repo and run the example:

git clone https://github.com/filipre/signalbot.git
cd signalbot/example
export SIGNAL_SERVICE="127.0.0.1"
export PHONE_NUMBER="+49123456789"
pip install signalbot
python bot.py

Error message:

~/signalbot/example$ python bot.py Traceback (most recent call last): File "/home/ubuntu/signalbot/example/bot.py", line 44, in main() File "/home/ubuntu/signalbot/example/bot.py", line 17, in main signal_service = os.environ["SIGNAL_SERVICE"] File "/usr/lib/python3.10/os.py", line 680, in __getitem__ raise KeyError(key) from None KeyError: 'SIGNAL_SERVICE' (.venv) ubuntu@ip-172-26-13-108:~/signalbot/example$ export SIGNAL_SERVICE="127.0.0.1" (.venv) ubuntu@ip-172-26-13-108:~/signalbot/example$ export PHONE_NUMBER="+xxxx" (.venv) ubuntu@ip-172-26-13-108:~/signalbot/example$ python bot.py WARNING:root:[Bot] Could not initialize Redis. In-memory storage will be used. Restarting will delete the storage! INFO:root:[Bot] Producer #1 started INFO:root:[Bot] Consumer #1 started INFO:root:[Bot] Consumer #2 started INFO:root:[Bot] Consumer #3 started ERROR:asyncio:Task exception was never retrieved future: exception=GroupsError()> Traceback (most recent call last): File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) File "/usr/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection raise exceptions[0] File "/usr/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "/usr/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut File "/usr/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 132, in get_groups
resp = await session.get(uri)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/client.py", line 581, in _request
conn = await self._connector.connect(
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 544, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 944, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
raise last_exc
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/ubuntu/.venv/lib/python3.10/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:80 ssl:default [Connect call failed ('127.0.0.1', 80)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 227, in _detect_groups
self.groups = await self._signal.get_groups()
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 139, in get_groups
raise GroupsError
signalbot.api.GroupsError
Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 20, in receive
async with self.connection as websocket:
File "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 642, in aenter
return await self
File "/home/ubuntu/.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 "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 663, in await_impl
_transport, _protocol = await self._create_connection()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection
raise exceptions[0]
File "/usr/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
File "/usr/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 324, in _produce
async for raw_message in self._signal.receive():
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 25, in receive
raise ReceiveMessagesError(e)
signalbot.api.ReceiveMessagesError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 294, in _rerun_on_exception
await coro(*args, **kwargs)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 336, in _produce
raise SignalBotError(f"Cannot receive messages: {e}")
signalbot.bot.SignalBotError: Cannot receive messages: [Errno 111] Connect call failed ('127.0.0.1', 80)
WARNING:root:Restarting coroutine in 1 seconds
INFO:root:[Bot] Producer #1 started
Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 20, in receive
async with self.connection as websocket:
File "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 642, in aenter
return await self
File "/home/ubuntu/.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 "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 663, in await_impl
_transport, _protocol = await self._create_connection()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection
raise exceptions[0]
File "/usr/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
File "/usr/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 324, in _produce
async for raw_message in self._signal.receive():
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 25, in receive
raise ReceiveMessagesError(e)
signalbot.api.ReceiveMessagesError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 294, in _rerun_on_exception
await coro(*args, **kwargs)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 336, in _produce
raise SignalBotError(f"Cannot receive messages: {e}")
signalbot.bot.SignalBotError: Cannot receive messages: [Errno 111] Connect call failed ('127.0.0.1', 80)
WARNING:root:Restarting coroutine in 2 seconds
INFO:root:[Bot] Producer #1 started
Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 20, in receive
async with self.connection as websocket:
File "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 642, in aenter
return await self
File "/home/ubuntu/.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 "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 663, in await_impl
_transport, _protocol = await self._create_connection()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection
raise exceptions[0]
File "/usr/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
File "/usr/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 324, in _produce
async for raw_message in self._signal.receive():
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 25, in receive
raise ReceiveMessagesError(e)
signalbot.api.ReceiveMessagesError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 294, in _rerun_on_exception
await coro(*args, **kwargs)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 336, in _produce
raise SignalBotError(f"Cannot receive messages: {e}")
signalbot.bot.SignalBotError: Cannot receive messages: [Errno 111] Connect call failed ('127.0.0.1', 80)
WARNING:root:Restarting coroutine in 4 seconds
INFO:root:[Bot] Producer #1 started
Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 20, in receive
async with self.connection as websocket:
File "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 642, in aenter
return await self
File "/home/ubuntu/.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 "/home/ubuntu/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 663, in await_impl
_transport, _protocol = await self._create_connection()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection
raise exceptions[0]
File "/usr/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
File "/usr/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 324, in _produce
async for raw_message in self._signal.receive():
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/api.py", line 25, in receive
raise ReceiveMessagesError(e)
signalbot.api.ReceiveMessagesError: [Errno 111] Connect call failed ('127.0.0.1', 80)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 294, in _rerun_on_exception
await coro(*args, **kwargs)
File "/home/ubuntu/.venv/lib/python3.10/site-packages/signalbot/bot.py", line 336, in _produce
raise SignalBotError(f"Cannot receive messages: {e}")
signalbot.bot.SignalBotError: Cannot receive messages: [Errno 111] Connect call failed ('127.0.0.1', 80)
WARNING:root:Restarting coroutine in 8 seconds

Please let me know if you need any further details to help debug this! Not sure what is going wrong with the coroutine / connect call failed error...

@Kariton
Copy link
Contributor

Kariton commented Jun 2, 2024

Hello,

your command does make the signal-cli-rest-api available on port 8080.

docker run -p 8080:8080

signalbot tries to use port 80 - which does not work because there is no signal-cli-rest-api on that port. :)

@Era-Dorta
Copy link
Collaborator

Closing due to inactivity, please re-open if you are still having issues.

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

4 participants
@Era-Dorta @jaanli @Kariton and others