I am writing an app that when I send a soap request to the server I will receive a soap response that I will store some of its elements as an object's properties.
Are there any ways that I can keep observing changes of the response without manually shooting the same soap request continuously to the server?
If you don't want to query the server each time, you may try to integrate a websocket implementation, so you can listen a specific for any change events that will be sent by the server.
Finally sorted. I have found that I can http SUBSCRIBE to the server to receive http notification (http response with "notify" header and XML body) whenever there is any change to the song that I am playing.
I have then built a http server in my iPhone app (GCDWebServer) to enable the listening to the above http notifications. These notifications are considered as "request" instead of response from the server's perspective.
Related
Recently , I am working on a rare iOS task. I am going to transfer the audio data to the server when recording . The server only accept http post chunked request. And the params of request should be set in the http request header. Has anyone ever done such a thing before ?
I think I described almost everything I need in title. So there is some WMB flows. And one wait for the answer in queue. I need to throw exception if there will be no message in queue after timeout.
Thank you for your time
Yes it is possibe, but you will need to develop it in your flows. MQ is made for asyncronous communication, so a timeout is not something which is native to it. I can think of 2 possible solutions now:
Use the TimeoutControl and TimeoutNotification nodes in your flows
In the flow which sends the request, after sending the request you add a TimeoutControl node and set up the desired timeout.
Create a new flow, which starts with the TimeoutNotification flow. In that flow you send your timeout error if the response has not yet been received.
And to know which response has been received you can use different methods, for example the flows sending the request and receiving the response could maintain a database table, or you could store this information in a queue as well.
Start waiting for the response after sending the request
Set up the response handler flow to start with an MQ Input followed by an MQ Get node. You listen for the response with the MQ Get, on which you can set a wait interval, that will be your timeout threshold. The MQ Input gets technical messages sent by the request sender flow after sending the request.
This is a worse solution then the first, as you will block a message flow thread while listening for the response.
Or you can just make 1 flow to send the request and receive the response, receiving the response with an MQ Get node.
This is even worse as you will need to turn off transactionality for the MQ Output sending the request.
I'm developing a messaging system in Delphi. I'm using idTcpServer in my Server Application and idTcpClient in my client application. the client application pings the server every 10 seconds to see if the connection is active and tell the server to set the status of the user to Online. and also the user may send messages to his contacts. all these requests are followed by a response from server which i get by socket.readln command right after i send the request. for example for pinging the server:
TcpClient.socket.writeln('i am online');
if TcpClient.socket.readln = 'ok' then
begin
{commands}
end;
I also check for new messages using Long Polling. I send 'check for new messages ' + timestamp from tcpClient and then on the server, I check the database for new messages newer than the timestamp i recieved in a While loop so when there is a new message the loop breaks and notification is sent to the client.
But this system doesn't work for me. Sometimes I get the responses intended to be for checking for new messages when the client application is pinging the server.
I have developed the same system in php without a problem. but here there must be a problem.
I think it is not asynchronous. what should I do?
Regarding the check for new messages request, the server should not be looping waiting for new messages to arrive. Either there are new messages available at the time of the request or there are not. Get the request, do the query, report the result, and move on. The client can send a new check for new messages request periodically. Alternatively, have the client tell the server one time that it wants new messages, and then the server can actively push new messages to the client in real-time as they arrive on the server, instead of polling for them (similar to IMAP's IDLE command).
I would suggest you redesign your communication protocol to run asynchronously. Most modern IM services are asynchronous. When the client sends a request, do not expect a reply right away. Just let the client move on to other things. Have it run a separate timer/thread that reads all inbound data. When a reply does arrive, the client can act on it. If needed, include an identifier in the request that gets echoed in the reply so the client can keep track of the requests it sends. This also allows the server to use asynchronous processing on its end, so if a request takes a long time to run, the server can push it off to another thread/process and continue processing other requests in the meantime. Send the final reply when it is ready.
If I have a app in which the user can set remainders for when there is a new article in a blog. And we can find out if there is a new article in the blog by sending a api request. How should I make the app to continuously send requests to the api. Is there an other way to do this or should we just keep sending requests to api continuously. And if so in how much time interval should we send it.
Thanks
In this case delegating the check for updates to some sort of server side would be ideal. The server side logic could send push notifications to your clients.
This question is mostly an HTTP question, I am working on an iOS app, though this question is not specific to iOS.
I would like to use persistent connections, and have no problems doing so, until an HTTP response uses the chunked transfer type, instead of explicitly sending Content-Length. The response itself works normally, and would work if I never needed to cancel the response. This response can take a while to send the response(it can take minutes and will never send the final 0 chunk), and frequently, I would like to cancel this request(and response) and send a new request on the same connection.
With HTTP/1.1, how can I cancel the chunked response response without closing the connection?
My current workaround is to not use persistent connections, but then I lose all the benefits of using persistent connections, which makes initiating these requests much slower.
You can't cancel it. There is nothing in the HTTP protocol that allows you to interrupt a HTTP response. You either need to read and discard the entire response or close the connection. However, you can issue another HTTP request on the same connection while the server is still sending the response, but you still have to process the entire response to the original request.