I have written a service for handling sip call. I want to make some additional feature to restrict a call time by configuring a fix time or handling the call time value by sending with some parameter.
Once a sip call got established generally it will be terminate with the end users response as CANCEL or BYE but before that if i want to restrict it to some fixed time, is it possible ? Once a sip call got established if i've fixed a time as 5 minutes so even if the end user doesn't will to end the call, the call should be terminate automatically after 5 minutes.
I've gone through expires header which doesn't seems to be helpful on this.
One option is this can be done at client. In the client we can have configurable timer. Once the call starts start the same and when it fires terminated the call.
Other option is to do at the server side where server does the same.
Yes, it's possible. It's usually better to do that on the server side as it's usually tied to charging. Like if user runs out of money terminate the call.
You need your call to go through a Back to Back User Agent Application which will handle that. The B2BUA which will start a timer which after it expires, will be responsible for sending the BYE to both legs to terminate the call. You can do this on Restcomm SIP Servlets, there is an example of a B2BUA at https://github.com/RestComm/sip-servlets/tree/master/sip-servlets-examples/call-forwarding.
If you want to do this on the client, you will need to have control over the client code and implement a similar logic, ie starts a timer that will send the BYE when it expires.
Related
I have a process in the back-end which will take take on average 30 to 90 seconds to complete.
Is it better to have a font-end react app make ONE API call and wait for back-end to complete and process and return the data. Or is it better to have the front-end make multiple calls, lets say every 2 seconds to check if the process and complete and get back the result?
Both are valid approaches. You could also report status changes with websocket so there's no need for polling.
If you do want to go the polling route, the general recommendation is to:
Return 202 accepted from your long-running process endpoint.
Also return a Link header with a url to where the status of the process can be read.
The client can then follow that client and ping it every x seconds.
I think it's not good to make a single API call and wait for 30-90 seconds to get a response. Instead send a response immediately mentioning that the request is successful and would be processed.
Now you can use web sockets or library like socket.io so that the server can communicate directly to the client once the requested processing is complete.
The multiple API calls to check if server is done or server has any new message is called polling and is not much efficient but it is still required in old browsers which don't support web sockets. Socket.io support s polling automatically in old browsers.
But, yes if you want you can do multiple calls to check if server is done processing, but I would prefer server to communicate back to the client , it is better.
I am using webrtc.io to create the socket connections for my audio, video chat application. I want to preserve all the socket connection so that I can send updates to all the end users when the node.js server is restarted.
I am using Mongodb as the database for this application. Is there any way to store in the database and retrieve it back when the server is restarted?
I'm going to give you a common life situation to explain this.
Suppose you have a mobile phone that you cannot make calls from and you can only receive calls.
Someone calls you and you can talk to them, messages pass backwards and forwards on a constant connection. This was better than SMS because you could only respond to an SMS that was sent to you as well but now you have this constant connection to talk freely on.
Now in those statements I just described what Websockets are and the difference between that an Http. Next I'll apply this to what you are asking.
Now suppose on this phone where you can only keep talking on calls you receive from someone else, your battery runs out. You find a power source to plug into and get your phone working again. So do you expect your phone to just suddenly re-establish the call that dropped when your battery ran out?
You do not initiate the connection you are talking about. So you cannot "make the call back" or "re-establish the call". This is a strictly "the customer calls you" scenario.
The best you can do is maintain the session state to the subsequent re-connection "picks up where you left off". But on a hang-up the client has to call you back.
For better availabilty you need to proxy the connection and share over multiple application server nodes, all with access to the same session state.
I have problem detecting the loss of socket connection in CF app for PDA device.
I have static class that has static methods for communication (Connect(), Write(), Disconnect()). Static because all forms can call Write method.
In Connect method i call socket.Connect(ipEndpoint);
But when device hasn't got wifi connection program halts at this line for about 20 s which is too long. Also if user starts Write() method (saving some data) and wifi connection is lost, user cannot interact with form and thinks that application frizzed. Since there is no timeout option for CF socket connection, what is the best way to control socket behavior?
My idea is to show some kind of "Communication form" when socket doesn't response for 5 seconds which will try to reestablish connection. This form will have graphical indicator (rotating clock or something like that) to show user that program is trying to connect and exit button if user decides to exit app. If socket.connect succeeds, i will show last used form to user.
I assume that this has to be done with Threads, but since i don't have experience with it. i need help how to manage this behavior.
You can call Socket.BeginConnect() to launch the connect in the background. You can then specify the callback method that will get invoked when the socket has connected (or timed-out). Additionally, to implement your progress bar counting down as it tries to connect you can do:
IAsyncResult ar = moSocket.BeginConnect(...)
And then you can have your connection form use a timer to count down, checking the status of the connection by calling:
ar.IsComplete
Polling is not very efficient, but in this case it works well with your described pop-up connection form.
I have a java based web application(struts 1.2). I have a requirement to display a status on the frontend (jsp). Now the status might change which my server gets notified by another server. But I want this status change to be notified to the browser.
I don't want to make a refresh at intervals. Rather I have to implement something like done in gmail chat, ie. the browser gets notified by changing events on the server.
Any ideas on how to go about this?
I was thinking on lines of opening a request to server for status, and at the server end I would hold the request and wouldn't respond back until there is a status change. Any pointers, examples on this?
Best possible solution will be to make use of XMPP protocol. It's standardized and a lot of open source solutions will get you started within minutes. You can use combination of Smack, StropheJS and Openfire to get your java based app work as desired.
There's a method called Long Polling (Comet). It basically sends a request to the server. The request thread created on the server simply waits for new data for the user, with a time limit of maybe 1 minute or more. When new data is available it is returned.
The main problem is to tackle the server-side issue, you don't want to have one thread for every user just waiting for new data. Of course you could use some asynchronous methods depending on your back-end.
Ref: http://en.wikipedia.org/wiki/Push_technology
Alternative way would be to use WebSockets. The problem is that it's not supported by all browsers today.
I am working on a Chatting application (needs to connect to a server) on iPhone. The sending packet from iPhone shouldn't be a problem.
But I would like to know whether it is possible for iPhone to establish a incoming socket connection to server continuously or forever under mobile environment.
OR What do I need to do to give the connection alive ? Need to send something over it to keep it alive ?
Thanks.
Not sure why you want to have chatting app to have persisted connection... I'd better use SMS like model. Anyways, Cocoa NSStream is based on NSSocket and allows a lot of functionality. Take a look at it.
Response to the question. Here is in a nutshell, what I would do:
Get an authentication token from the server.
this will also take care of user presence if necessary but now we are talking about the state; once presence is known, the server may send out notifications to clients that are active and have a user on their contact list.
Get user's contact list and contact presence state.
When a message send, handle it according to addressee state, i.e. if online, communicate back to the other user, if offline, queue for later delivery or reject.
Once token expires, reject communication with appropriate error and make the client to request a new token.
Communication from server to client, can be based on pull or push model. In first case, client periodically makes a request and fetches all messages. This may sound not good but in reality, how often users compose and send messages? Several times a minute? That's not too much. So fetching may happen every 5-10 seconds.
For push model, client must be able to listen and accept connections.
Finally, check out SIP, session initiation protocol. No need to use full version of it though. Just basic stuff.
This is very rough and perhaps simplified. I don't know the target complexity of your chatting system. For example, the simplest thing can also be that server just enables client to client communication by distributing their end points and clients take care of everything themselves.
Good luck!
Super out of date response, but maybe it will help the next person.
I would use xmppframework and a jabber server.