I need to connect to an XMPP server over websocket on iOS (ws://chat.something.com:1234/websocket). I am using XMPPFramework, but I cannot find a way to make it connect over websocket.
I found this answer https://stackoverflow.com/a/23114564/310121 that suggests that XMPPFramework doesn't support this. As far as I can tell, that seems to be true.
So is there any way to connect to an XMPP server over websocket on iOS without writing your own library or extending XMPPFramework (or some alternative library) to support this?
XMPPFramework uses TCP sockets. It has not provided any API's or provision for websockets.
In order to connect with your server using websockets, you will have to alter XMPP Library's code.
I had the same issue, and i resolved it by replacing XMPPStream class of XMPPFramework (that deals with the actual TCP socket connection) with custom stream class, and used SocketRocket library to connect over websocket with my server.
Related
I'm doing a project of mediasoup with swift. The mediasoup server is using protoo server. But there is no protoo client on swift. I tried to use WebSocket. It also fail. Is there any way to connect protoo server on swift?
I'm looking to build a pair of apps that work in a similar way to iTunes and the Remote app for iOS... Is there a framework for connecting iOS and MacOS over wifi?
Bluetooth is something I'd like to avoid and there's no need for a web service, I'm just looking to control my Mac app remotely from the phone.
Thanks in advance.
Id say the most ideal way to accomplish this is via the Bonjour protocol.
Here is a great article on the subject, http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/.
Good thing with using Bonjour in iOS is it also works via Bluetooth.
Hope this helps !
here is an example project which exchange the data between iphone and iMAC with WiFi connectivity.
https://github.com/boobalaninfo/Bonjour-iOS-MAC-Apps
Use bonjour to search for devices. Then use CocoaAsyncSocket to send and receive data. It works like a charm.
Little info about AsyncSock:
GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries.
Here are the key features available in both:
Native objective-c, fully self-contained in one class. No need to muck
around with sockets or streams. This class handles everything for you.
Full delegate support Errors, connections, read completions, write
completions, progress, and disconnections all result in a call to your
delegate method.
Queued non-blocking reads and writes, with optional timeouts. You tell
it what to read or write, and it handles everything for you. Queueing,
buffering, and searching for termination sequences within the stream -
all handled for you automatically.
Automatic socket acceptance. Spin up a server socket, tell it to
accept connections, and it will call you with new instances of itself
for each connection.
Support for TCP streams over IPv4 and IPv6. Automatically connect to
IPv4 or IPv6 hosts. Automatically accept incoming connections over
both IPv4 and IPv6 with a single instance of this class. No more
worrying about multiple sockets.
Support for TLS / SSL Secure your socket with ease using just a single
method call. Available for both client and server sockets.
Do we have facility for working with WebSockets in AFNetworking for iOS?
No unfortunately AFNetworking doesn't support websocket handling, I am using SocketRocket for websocket handling.
I am trying to use the MQTT protocol and am an amateur with this. I tried the objective-C code over Mosquitto library using MQTTKit (https://github.com/jmesnil/MQTTKit).
I am able to use it to publish messages to some test servers and things are working fine but still I have some basic questions, not so clear to me:
Does Mosquitto library include web sockets too underneath?
Is it possible to create a connection, subscribe to a topic and then server can also publish messages to device with realtime behavior? In other words, can we use it for real time communication between server and client (the iOS device in this case) bidirectional?
The mosquitto library does not support websockets, it is mqtt only.
Yes, mqtt is a bidirectional protocol. I believe there are difficulties with keeping a long term socket open on iOS that mean it isn't as straightforward to support as you might like. I'm not familiar with iOS at all though.
1.the mosquitto library of javascript has support websocket. you can go http://mosquitto.org/download/ to download.
2.mosquitto support MQTT protocol. When the connection was established, the mosquitto will send PINGREQ message for keep heartbeat.(the keep alive time please see MQTT protocol). the MQTT protocol is Publish / Subscribe (PubSub) model.So the server(broker) is central. Client subscribe topic, other client can receive message, and clietn can publish message to the another topic.That's all, you only need to set appropriate topic.
I am trying to establish BIS Socket connection. I am able to establish BIS Http connection from my service provider.
I have downloaded one chat application that checks network types supported by my device/service plan which has following list:
1)BIS-Http : OK
2)BIS-SOCKET :OK
3)BES-HTTP : NA
4)BES-SOCKET : NA
5)TCP-HTTP : BAD DNS
6)TCP-SOCKET : TIMED OUT
As I know direct TCP is not supported by my service provider. So I would like to use BIS-Socket connection.
Can anypne please help me in achieving this type of connectivity?
Use of BIS-B connectivity is available to members of the Blackberry Developer Alliance program. Not being a member I can't tell you if if supports random socket connection or not.
Normal BIS access available through the API supports web protocols and is not a TCP/IP protocol between the Blackberry and the BIS. Hence the deviceSide= parameter in the connection stream. DeviceSide=true the Blackberry uses an internal TCP stack to establish a connection through direct access to the wireless carrier's access point (APN). DeviceSide=false (the default) the Blackberry sends the necessary data to the BIS (or BES) MDS server using a presumably proprietary protocol. The MDS server then establishes the TCP connection on behalf of the Blackberry.
If direct TCP is not available to you, and you can't use BIS-B, you will have to carry your data on top of an http connection. In most cases this is straight forward and works quite well.
To use BIS you need pay $2000. Have you done that? how you know you're using BIS?