iOS XMPP chat through HTTP proxy

2019-07-20 17:29发布

I have an iPhone application which works with 2 services:

  1. work with REST service over http - use AFNetworking
  2. have XMPP chat over TCP - use XMPPFramework https://github.com/robbiehanson/XMPPFramework

My iPhone uses corporate network with proxy, so I set HTTP proxy in Settings http://qblx.co/1eJ9TwI

With this proxy settings all requests to REST service go through this proxy. But, my application connects direct to Chat server, without proxy.

How to make Chat works through proxy? As I can see, XMPPFramework uses GCDAsyncSocket as a transport https://github.com/robbiehanson/CocoaAsyncSocket

Do you have any suggestions how to setup Chat through proxy?

1条回答
贪生不怕死
2楼-- · 2019-07-20 18:13

XMPP by default uses plain TCP socket connection, which is not able to route via HTTP proxy. You can:

  • if your proxy supports HTTPS/Tunneling, try to use 443 port for your XMPP service, or forward 443 port to default XMPP service port(5222) on your router.
  • if your proxy supports SOCKS, try to use ProxyKit, but it may need to modify XMPPFramework code
  • You can try to use XMPP with HTTP or Websocket transport, but XMPPFramework did not support it and you may need to find/write different library
查看更多
登录 后发表回答