通过HTTP代理的iOS XMPP聊天 [英] iOS XMPP chat through HTTP proxy
问题描述
我有一个可以使用2种服务的iPhone应用程序:
I have an iPhone application which works with 2 services:
- 通过http使用REST服务-使用AFNetworking
- 通过TCP进行XMPP聊天-使用XMPPFramework https://github.com/robbiehanson/XMPPFramework
我的iPhone将公司网络与代理一起使用,因此我在设置"中设置了HTTP代理 http://qblx.co/1eJ9TwI
My iPhone uses corporate network with proxy, so I set HTTP proxy in Settings http://qblx.co/1eJ9TwI
使用此代理设置,所有对REST服务的请求都将通过此代理. 但是,我的应用程序无需代理即可直接连接到聊天服务器.
With this proxy settings all requests to REST service go through this proxy. But, my application connects direct to Chat server, without proxy.
如何通过代理使Chat正常工作? 如我所见,XMPPFramework使用GCDAsyncSocket作为传输 https://github.com/robbiehanson/CocoaAsyncSocket
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?
推荐答案
默认情况下,XMPP使用简单的 TCP 套接字连接,该套接字无法通过 HTTP 代理进行路由.您可以:
XMPP by default uses plain TCP socket connection, which is not able to route via HTTP proxy. You can:
- 如果您的代理支持HTTPS/隧道,请尝试将443端口用于XMPP服务,或将443端口转发到路由器上的默认XMPP服务端口(5222).
- 如果您的代理支持SOCKS,请尝试使用 ProxyKit ,但可能需要修改XMPPFramework代码
- 您可以尝试通过HTTP或Websocket传输使用XMPP,但是XMPPFramework不支持它,您可能需要查找/编写其他库
- 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
这篇关于通过HTTP代理的iOS XMPP聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!