Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIP Proxy example didn't implement INVITE #1082

Open
nganju98 opened this issue Mar 6, 2024 · 4 comments
Open

SIP Proxy example didn't implement INVITE #1082

nganju98 opened this issue Mar 6, 2024 · 4 comments
Labels

Comments

@nganju98
Copy link

nganju98 commented Mar 6, 2024

Hi, I'm trying to implement a dirt simple SIP Proxy with this library. I looked at the SIP Proxy example where it allows clients to register, but it doesn't implement a response to an inbound SIP Invite request. Is there a simple example I can use to make a SIP Invite response that builds up all the appropriate headers? Like it should fill out the Contact and RecordRoutes headers and the body should be from the registered client, and send that response back to the inbound caller.

Really, I want the same server to be both the Proxy for client lookups, and the answering UserAgent Server as well, that answers as like an IVR to the caller. Inbound callers (Twilio's implementation in particular) expect the SIP Invite redirect with the Contact header first. If I just send 200 OK back on the first SIP Request, the client never sends back an ACK. I think I need to send the Invite response with Contact/RecordRoutes header first, then I'll get another incoming INVITE from the same client, then answer it normally.

@DavidMartynWood
Copy link
Contributor

You're trying to build something really complicated, and I think trying to use this library to do something like that is unlikely to lead to success.
As I understand it you want to answer a call, do some IVR, and the forward the call to to something.
There are products like asterisk/freeswitch and kamailio that exist to do stuff like this. Those are not simple solution either. But if you want to comply with standards it's probably worth looking into it.

@nganju98
Copy link
Author

nganju98 commented Mar 7, 2024

No, I don't want to do some IVR and then forward the call. I just want to forward the call immediately, in other words just act exactly like a Proxy Server by using the Contact headers. This is not a complex use case, I feel like it's 15 lines of code on top of the massive standards-compliant library you guys have already built.

The next server that I forward it to is the one that has the IVR. The IVR destination server is also based on this library, it would be great if I could make the Proxy Server based on this library too, then I would have less variety of products to support and it would all be in .Net.

@DavidMartynWood
Copy link
Contributor

DavidMartynWood commented Mar 7, 2024

Thanks for the explanation, that makes more sense now. Just to clarify, I'm a minor contributor to this project, and by no means a sip expert like the maintainers.

I'm not sure if sipsorcery respects record-route headers when sending an ACK, or if it replies to the contact in the sip invite ok. And indeed I'm not actually sure what it's supposed to do according to the standard. I recently had a similar problem in this area and couldn't bottom it out so implemented a workaround for my scenario.

To try to understand what it's doing I would use wireshark on the client and see where it's trying to send the ack to. That might give you some clues.

Then if you can include the full sip messages for your flow somebody more knowledgeable might be able to help you out with what eitherinyou are doing wrong, or what might need implementing in sipsorcery.

I'll be watching this in the hope somebody else jumps in with an answer. Routing in sip is hard to get your head around.

@sipsorcery
Copy link
Member

Sounds like you're attempting to build a Stateful Proxy (like OpenSER, Kamailio) or a B2BUA Server (like Asterisk and FreeSWITCH w/o media).

Both options are feasible with this library but definitely not in 15 lines of code, probably closer to 1500.

There is an example of a B2BUA here.

@sipsorcery sipsorcery added the sip label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants