sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.44k stars 438 forks source link

How to use sipsorcery .net core at Web side? #290

Closed thornzz closed 4 years ago

thornzz commented 4 years ago

Hi,

Im using sipsorcery library for .net core 3.1 since 2-3 days. I have developed a sipsoftphone at .net core Windows Forms. Everything is working well. But i wonder can i use same library for asp.net core 3.1 and make a web sip client? Or which sipsorcery library i have to use for develop a web sip client?

sipsorcery commented 4 years ago

Depends what you mean by "Web SIP client". A web browser cannot natively act as a SIP User Agent. What it can do is act as a WebRTC peer which is roughly the equivalent of a VoIP client BUT is NOT compatible with SIP clients like IP Phones, SIP softphones etc.

You can create a bridge between a SIP device and a WebRTC peer so they can call each other, see the SIPToWebRTCBridge example. There are also server applications that will do this bridging for you: Asterisk, FreeSWITCH etc.

If all you're interested in is an ASP.NET application that can host calls between browsers take a look at this example. IN this case the ASP.NET application is acting as a peer in a WebRTC call.

There are lots of permutations and there are many other options, sip.js is another solution that fits in between SIP and WebRTC.

thornzz commented 4 years ago

My main goal ; there is an example of Sipsoftphone written with .net core 3.1 that i wanna run this at web browser. I wanna make call, answer calls , attended, blind transfer, hold etc.. do this every possible action at Web side. Our pbx is 3cx and they got webclient and working well at any web browser and doing this actions. So acting as a peer in a Webrtc will do this job done?

sipsorcery commented 4 years ago

What you need is sipjs or equivalent javascript library. It handles the SIP signalling and uses the browser's inbuilt WebRTC stack for the media. The tricky bit is that your PBX needs to understand the additional layers WebRTC uses for transporting the media.

There's a very basic example of using sip.js with the sipsorcery library here. The example program is acting in the same role as your 3CX server. It's a console application but could be an ASP.NET application instead.

If you're looking to replace 3CX with a custom application it will be a huge amount of work. If you just want a custom web based softphone that can be used with 3CX then sip.js can do that for you.

thornzz commented 4 years ago

Thanks for your answer. But i wanna ask another question that there is a WebRTC library named RTCMultiConnection.js i have got a projects using this library. I have got a web project and doing many to many video calls on it. But this library is not updating its self since 1-2 years and there is no support. So can i make many to many video calls projects with using sipsorcery Webrtc library?

sipsorcery commented 4 years ago

You're probably using the old WebRTC shim adapter which used to be required to accommodate the differences between browser WebRTC implementations. You don't need it anymore. All major browsers now have the WebRTC stack in built. For example you can simply use var pc = new RTCPeerConnection(); without any javascript library includes.

thornzz commented 4 years ago

So whats sipsorcery webrtc library do? Whats the benefit of using it? And You have mentioned up there SipToWebRTCBridge i wanna ask another question about it. Our pbx system not supporting Sip over websocket so i cant use sipjs coz its using wss protocol. Can i use SipToWebRTCBridge way and listen ws request to use sipjs?

sipsorcery commented 4 years ago

So whats sipsorcery webrtc library do?

When you create a WebRTC call it's always between 2 Peers. One Peer will usually be a browser, and often the other Peer will be as well. For some applications it may be useful to act as the second Peer. For almost all the WebRTC Examples in this project a console application using the sipsorcery library is acting as the second peer.

Whats the benefit of using it?

If your custom application is acting as a WebRTC Peer you can control the audio/video/data channel from it instead of only being able to use a browser based application.

Our pbx system not supporting Sip over websocket so i cant use sipjs coz its using wss protocol. Can i use SipToWebRTCBridge way and listen ws request to use sipjs?

I don't know anything about how the 3CX Web Client works. Since it seems to be a Browser Extension rather than a javascript app my guess is it doesn't use SIP between the Web Client and the 3CX server but instead uses HTTP/REST requests or similar. If they have a public API you could possibly try and hook into that to build a web phone.

If you really do want to build a SIP based Web Client that works with 3CX (and 3CX don't support web sockets) then it would be possible but also tricky:

There are other PBX'es that support SIP over web sockets and support WebRTC based media directly so your life would be mch easier using one of them:

The only place the sipsorcery library could help here is with the middle SIP Proxy to accept web socket connections step. But there are already existing tried and tested SIP Proxys so why re-invent the wheel?

thornzz commented 4 years ago

3CX server webclient using wss connection but they are not supporting to use of public. We have to use 3cx there is no other option. So we need Sip Proxy. Could you give me any name of Sip proxy applications?

sipsorcery commented 4 years ago

https://www.kamailio.org

thornzz commented 4 years ago

So kamailio is an open source sip server. Will kamalio in the middle of sipjs Web Application and 3CX Server as a Sip Proxy right?

sipsorcery commented 4 years ago

Yes that's how I see it working. It could be a tricky job though, there's a lot of moving parts...

thornzz commented 4 years ago

Yes that's how I see it working. It could be a tricky job though, there's a lot of moving parts...

What do you think about Janus Sip Gateway ? Does it make sense to prefer Janus Sip Gateway instead of using a sip proxy?

sipsorcery commented 4 years ago

I don't know much about how the SIP gateway in Janus works but I suspect it's more geared towards acting as a application end point (user agent) rather than being a SIP Proxy. I'd put Janus in the same category as Asterisk and FreeSWITCH in that you could use it as a one-stop shop to replace 3CX and work with your web based SIP client.

If you want to keep 3CX I'd go for a product designed to be a SIP Proxy.

thornzz commented 4 years ago

Okay . Thanks for your answers. @sipsorcery 👍