mqtt_cpp icon indicating copy to clipboard operation
mqtt_cpp copied to clipboard

Support for HTTP proxy with authentication

Open shantanu1singh opened this issue 4 years ago • 3 comments

Question: Does the library have support for HTTP proxies with authentication using the mqtt_tls_client_ws() API?

For example, the Paho Mqtt library supports HTTP proxies with authentication: https://github.com/eclipse/paho.mqtt.c/pull/542#issuecomment-430072283

shantanu1singh avatar Sep 16 '20 18:09 shantanu1singh

No. I'm not sure but it seems that Boost.Beast doesn't support it so mqtt_cpp doesn't support it.

You can use the command proxytunnel. https://github.com/proxytunnel/proxytunnel It supports authentication.

proxytunnel -p proxy.sever:port -d target.host:port -a localport

for example,

proxytunnel -p proxy.yourdomain:8080 -d target.host:443 -a 10000

You can connect using 127.0.0.1:10000.

redboltz avatar Sep 16 '20 23:09 redboltz

ah, I see. Interesting, thanks for the link. I'll take a look

shantanu1singh avatar Sep 17 '20 01:09 shantanu1singh

I have made changes to my local copy of the repo to allow mqtt_cpp to support proxy servers. The footprint for my changes is relatively small - a new method was added to tcp_endpoint.cpp and ws_enpoint.cpp to find the lowest stream layer, and client.cpp has setters for the the proxy details and the connect_impl methods were changed to establish a TCP tunnel through the proxy server.

I have tested this using the proxy server called Squid and the results are good. Also, the changes do not break any of the existing system tests or unit tests. I don't think that I can easily add new system tests for this, as they would require a live proxy server.

ashbeitz avatar May 04 '21 00:05 ashbeitz