-
Notifications
You must be signed in to change notification settings - Fork 21
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
Need for HTTP proxy support #191
Comments
In order to support his we'll need to augment our ws_connect usage: https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession.ws_connect |
Two questions for @ares:
|
Ad 1. I'm afraid HTTPS is needed, is there a way to make it work with python 3.7? |
Aiohttp might support https proxies in a future version of Python 3.8. As of today they are not supported in any version. |
What we can do while still using aiohttp is done, in ansible/receptor#194. I have also opened ansible/receptor#197 for considering a switch to a different library. Testing for this issue should verify that it works with |
I'm unfamiliar with HTTP proxies. What's the basic procedure for testing this? Is it to install, configure with credentials, and run Squid, and then verify that traffic is sent through it? |
Yes, that's basically correct @Ichimonji10. Squid is as good a proxy server to test with as any. It might be nice to also verify that As an example of this, suppose you have a corporate network This puts you in a catch-22 situation if you want So in this circumstance you configure I'll leave it up to you how much of this you want to try to actually test. |
I am planning to tackle this earlier next week and all the information shared are really useful. |
Note: The fix for this is in ansible/receptor#194. |
This issue can be considered verified. The following was done to check it: While running: $ sudo tcpdump -aA -i lo -vvv "dst port 9999" And $ sudo tcpdump -aA -i lo -vvv "dst port 9998" The following receptor process was run: $ HTTP_PROXY=http://localhost:9998 poetry run receptor -d /tmp/ping ping node-a --peer ws://localhost:9999 Only the tcpdump listening to port 9998 events had an output. Then the $ poetry run receptor -d /tmp/ping ping node-a --peer ws://localhost:9999 This time, only the tcpdump listening to port 9999 events had an output. Which brings us to the conclusion the proxy information is being used as expected. Worth mentioning that receptor presented a stack trace with the |
I've reopened this as I am trying to get it to work with a real proxy and I am not able. Please take into consideration that I don't know much about proxy configuration and I might be doing something wrong. I tried to configure both nginx e squid and got similar issue:
To get that error I did the following: Configured nginx to run as a Web Socket proxy:
Started a receptor node to listen on port 9999 as the following: $ poetry run receptor --debug --node-id=controller -d /tmp/controller node --listen=ws://localhost:9999 Then tried to run another receptor node that would be using the proxy to access the node at port 9999: $ http_proxy=http://127.0.0.1:9990 poetry run receptor --debug --node-id=node-a -d /tmp/node-a node --listen=ws://localhost:9998 --peer=ws://localhost:9999 Then I could observe that node-a was really using the proxy as the following was seen on the nginx access.log:
The complete output of the controller node is the following: $ poetry run receptor --debug --node-id=controller -d /tmp/controller node --listen=ws://localhost:9999
INFO 2020-05-19 16:10:31,348 controller entrypoints Running as Receptor node with ID: controller
INFO 2020-05-19 16:10:31,349 controller controller Serving on ws://localhost:9999 And the complete output of the node-a node is the following: $ http_proxy=http://127.0.0.1:9990 poetry run receptor --debug --node-id=node-a -d /tmp/node-a node --listen=ws://localhost:9998 --peer=ws://localhost:9999
INFO 2020-05-19 17:54:19,148 node-a entrypoints Running as Receptor node with ID: node-a
INFO 2020-05-19 17:54:19,148 node-a controller Serving on ws://localhost:9998
INFO 2020-05-19 17:54:19,149 node-a controller Connecting to peer ws://localhost:9999
ERROR 2020-05-19 17:54:19,171 node-a ws ws.connect
Traceback (most recent call last):
File "/home/elyezer/code/receptor/receptor/receptor/connection/ws.py", line 57, in connect
async with aiohttp.ClientSession().ws_connect(
File "/home/elyezer/.cache/pypoetry/virtualenvs/receptor-hhoD6yiq-py3.8/lib64/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/home/elyezer/.cache/pypoetry/virtualenvs/receptor-hhoD6yiq-py3.8/lib64/python3.8/site-packages/aiohttp/client.py", line 733, in _ws_connect
raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 502, message='Invalid response status', url=URL('ws://localhost:9999') The |
After more investigation the configuration made for nginx provided on the previous comment happened to be a reverse proxy and we were looking for a forward proxy. That said, we would be using squid to play the forward proxy role and we could not have it to work with To get receptor working with With a certificate generated and signed, I've started receptor by running: $ poetry run receptor --debug --node-id=controller -d /tmp/controller --server-cert cert-signed.crt --server-key cert.key node --listen=wss://localhost:9999 And added the following line to the squid configuration:
So the complete squid config was like the following:
With squid running, then another receptor node was started by running: $ https_proxy=http://localhost:3128 poetry run receptor --debug --node-id=node-a -d /tmp/node-a node --server-disable --peer=wss://localhost:9999 Here is the complete output for the controller node: $ poetry run receptor --debug --node-id=controller -d /tmp/controller --server-cert cert-signed.crt --server-key cert.key node --listen=wss://localhost:9999
INFO 2020-05-20 13:02:22,247 controller entrypoints Running as Receptor node with ID: controller
DEBUG 2020-05-20 13:02:22,247 controller config Loading TLS Server Context
INFO 2020-05-20 13:02:22,261 controller controller Serving on wss://localhost:9999
DEBUG 2020-05-20 13:02:24,969 controller base TLSv1.3 connection with ('::1', 55374, 0, 0) using cipher TLS_AES_256_GCM_SHA384
and certificate None.
DEBUG 2020-05-20 13:02:24,970 controller base waiting for HI
DEBUG 2020-05-20 13:02:24,971 controller base starting normal loop
DEBUG 2020-05-20 13:02:24,972 controller receptor spawning message_handler
DEBUG 2020-05-20 13:02:24,972 controller base Watching queue <receptor.connection.ws.WebSocket object at 0x7ff964c0bcd0>
DEBUG 2020-05-20 13:02:25,072 controller receptor Constructing routing table
DEBUG 2020-05-20 13:02:25,074 controller receptor Routing updated. New table: [('controller', 'node-a', 1)]
DEBUG 2020-05-20 13:02:25,074 controller receptor Sending route advertisement aa7a99cb-94de-4022-8c8f-25f627fecaff seq 1
DEBUG 2020-05-20 13:02:25,074 controller receptor Advertised connections: {'node-a': 1}
DEBUG 2020-05-20 13:02:25,075 controller receptor Sent to node-a
DEBUG 2020-05-20 13:02:25,181 controller receptor Route advertisement 2fd8c4a0-322c-45f4-8b58-e1913b6961b2 seq 1 received From node-a via node-a
DEBUG 2020-05-20 13:02:25,181 controller receptor Constructing routing table
DEBUG 2020-05-20 13:02:25,182 controller receptor Routing not changed. Existing table: [('controller', 'node-a', 1)]
DEBUG 2020-05-20 13:02:25,282 controller receptor Constructing routing table
DEBUG 2020-05-20 13:02:25,283 controller receptor Routing not changed. Existing table: [('controller', 'node-a', 1)]
DEBUG 2020-05-20 13:02:25,283 controller receptor Sending route advertisement 5671da1f-c9d7-4009-99dd-3eabbd7f937e seq 2
DEBUG 2020-05-20 13:02:25,283 controller receptor Advertised connections: {'node-a': 1}
DEBUG 2020-05-20 13:02:25,284 controller receptor Sent to node-a
DEBUG 2020-05-20 13:02:25,388 controller receptor Route advertisement 6da40620-0739-494f-8f4a-c82d5e569913 seq 2 received From node-a via node-a
DEBUG 2020-05-20 13:02:25,388 controller receptor Constructing routing table
DEBUG 2020-05-20 13:02:25,390 controller receptor Routing not changed. Existing table: [('controller', 'node-a', 1)] And here is the complete output for the node-a node:
With all that we can close this issue, again, after verifying that not only receptor was trying to use the proxy (as verified by ansible/receptor#191 (comment)) but also it really works end to end. |
In case a user wants to let the traffic flow through HTTP proxy, receptor should provide options to specify proxy url together with username and password.
The text was updated successfully, but these errors were encountered: