pquiring / javaforce

JavaForce library for building powerful Apps and Services (Native Bindings for Camera, OpenGL, ffmpeg). Includes VoIP stack, PLC I/O and many apps.
http://pquiring.github.io/javaforce
GNU Lesser General Public License v3.0
55 stars 24 forks source link

Voip - Instant Messaging implementation #11

Closed ftasso closed 11 months ago

ftasso commented 1 year ago

Hello, I really appreciate this VOIP engine and I would like to integrate in my applications but there is a missing feature: the SIP Instant Messaging, Could you please insert this enhancement in you development plan?

Thank you, Fabrizio

pquiring commented 1 year ago

Sure, let me do some research and get started.

ftasso commented 1 year ago

Wonderful! Please, consider me a beta tester

pquiring commented 1 year ago

Beta available at https://javaforce.sourceforge.net/beta/ I've tested with FreePBX/Asterisk and the message looks good in Wireshark and I get a 202 but the message is not relayed to the other phone. Some websites claim FreePBX does NOT support MESSAGE types. Will try with jfPBX when I get to upgrading the server side logic. To use open the side panel, add a contact and then click on "Msg" button to send contact a message. Let me know. Thanks,

ftasso commented 1 year ago

Wow! Monday I will check your Beta version. I'm using Asterisk/FreePbx since 2013 and IM are fully supported. Thank you, Fabrizio

ftasso commented 1 year ago

Hello, I made some tests with my asterisk server 16.17.0 and: 1) "send" (SIPClient.message) is ok, it works fine. Take a look to the SIP handshake:

[2023/10/16 15:00:32] Client -> Server [2023/10/16 15:00:32] MESSAGE sip:99@192.168.1.211:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.240:5061;branch=z123456-y12345-38a6ede117c23bb2-1--d12345-;rport Max-Forwards: 70 Contact: sip:301@192.168.1.240:5061 To: "99"sip:99@192.168.1.211:5060 From: "301"sip:301@192.168.1.211:5060;tag=a535902ccf25cc58 Call-ID: 2a14e39018b3892e397 Cseq: 2 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce/45.2 Authorization: Digest username="301", realm="asterisk", uri="sip:192.168.1.211", nonce="1697461231/9ecfe31ad0d37ed8056c07a5d837f230", cnonce="2fc19991d5f1fd5e18b3892e39d90f03b77", nc=00000001, qop=auth, response="d4a8962e32e7f095813cff763656085b", algorithm=MD5 Content-Type: text/plain Content-Length: 6

test 4 [2023/10/16 15:00:32] Server -> Client [2023/10/16 15:00:32] SIP/2.0 202 Accepted Via: SIP/2.0/UDP 192.168.1.240:5061;rport=5061;received=192.168.1.240;branch=z123456-y12345-38a6ede117c23bb2-1--d12345- Call-ID: 2a14e39018b3892e397 From: "301" sip:301@192.168.1.211;tag=a535902ccf25cc58 To: "99" sip:99@192.168.1.211;tag=z123456-y12345-38a6ede117c23bb2-1--d12345- CSeq: 2 MESSAGE Server: FPBX-15.0.17.34(16.17.0) Content-Length: 0

2) I receive 3 notification for each IM message (SIPClientInterface.onMessage(...)). It seems my server don't understand the 200 acknowledge you send, please take a look:

[2023/10/16 15:01:04] Server -> Client [2023/10/16 15:01:04] MESSAGE sip:301@192.168.1.240:5061 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 From: sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 To: sip:301@192.168.1.240 Contact: sip:301@192.168.1.211:5060 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e CSeq: 59676 MESSAGE Max-Forwards: 70 User-Agent: FPBX-15.0.17.34(16.17.0) Content-Type: text/plain Content-Length: 103

303-URI-z9hG4bK16974612645323sMyYmzX3#TEST#16/10/2023 15:01:04

[2023/10/16 15:01:06] Client -> Server [2023/10/16 15:01:06] SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 Contact: sip:301@192.168.1.211:5060 To: "Unknown Name"sip:301@192.168.1.240 From: "Unknown Name"sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e Cseq: 59676 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce Content-Length: 0

[2023/10/16 15:01:06] Server -> Client [2023/10/16 15:01:06] MESSAGE sip:301@192.168.1.240:5061 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 From: sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 To: sip:301@192.168.1.240 Contact: sip:301@192.168.1.211:5060 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e CSeq: 59676 MESSAGE Max-Forwards: 70 User-Agent: FPBX-15.0.17.34(16.17.0) Content-Type: text/plain Content-Length: 103

303-URI-z9hG4bK16974612645323sMyYmzX3#TEST#16/10/2023 15:01:04

[2023/10/16 15:01:07] Client -> Server [2023/10/16 15:01:07] SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 Contact: sip:301@192.168.1.211:5060 To: "Unknown Name"sip:301@192.168.1.240 From: "Unknown Name"sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e Cseq: 59676 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce Content-Length: 0

[2023/10/16 15:01:07] Server -> Client [2023/10/16 15:01:07] MESSAGE sip:301@192.168.1.240:5061 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 From: sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 To: sip:301@192.168.1.240 Contact: sip:301@192.168.1.211:5060 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e CSeq: 59676 MESSAGE Max-Forwards: 70 User-Agent: FPBX-15.0.17.34(16.17.0) Content-Type: text/plain Content-Length: 103

303-URI-z9hG4bK16974612645323sMyYmzX3#TEST#16/10/2023 15:01:04

[2023/10/16 15:01:08] Client -> Server [2023/10/16 15:01:08] SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.1.211:5060;rport;branch=z9hG4bKPj7f8263cf-cab1-4725-bf46-652d69fcf557 Contact: sip:301@192.168.1.211:5060 To: "Unknown Name"sip:301@192.168.1.240 From: "Unknown Name"sip:303@asterisk;tag=d222620b-214f-47da-b971-746aa49bbd38 Call-ID: 2ac75f3e-3bfe-4955-afc3-4d7e1267f90e Cseq: 59676 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce Content-Length: 0

I hope this can help you. Bye, Fabrizio

pquiring commented 12 months ago

Real busy lately but I've performed some preliminary tests:

More to follow.

pquiring commented 12 months ago

Not making much progress on this. Asterisk MESSAGE support seems to be very buggy. I may release this "as is" since it works with jfPBX. Thanks,

ftasso commented 12 months ago

Ok Peter,

I will continue to investigate on this issue and I will inform you.

Thank you

pquiring commented 12 months ago

If you find any other phone apps with messaging capabilities and get some wireshark logs that may be helpful.

pquiring commented 11 months ago

Released JF/48.0 and jfPhone/1.25. Works with jfPBX but not Asterisk. Closing for now.

ftasso commented 11 months ago

Hello Peter, I made a new test using the last version you built, the 48.0, and the latest code of JFPhone.

Results:

MESSAGE im:301@192.168.1.211:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.240:5061;branch=z123456-y12345-a330276863349858-1--d12345-;rport Max-Forwards: 70 Contact: sip:303@192.168.1.240:5061 To: "301"sip:301@192.168.1.211:5060 From: "303"sip:303@192.168.1.211:5060;tag=9d3b9eff2fd32275 Call-ID: 100616d618bb3d403fd Cseq: 1 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce/48.0 Content-Type: text/plain Content-Length: 21

Test message from Fab

It seems wrong the prefix "im:301", my asterisk reply with this: PJSIP syntax error exception when parsing 'Request Line' header on line 1 col 34

Bye, Fabrizio

pquiring commented 11 months ago

Can you past the MESSAGE that is sent from Asterisk so I can compare?

ftasso commented 11 months ago

Hello, tomorrow I will repeat the sequence but the message I posted, retrieved from asterisk log, should be exactly the message you sent.

Bye

ftasso commented 11 months ago

Hello, I repeat the test using the official install of jfPhone 1.25:

your message from log:

[2023/11/10 13:22:59] Client -> Server [2023/11/10 13:22:59] MESSAGE im:301@192.168.1.211:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.240:5061;branch=z123456-y12345-11d9f2afba28ddf6-1--d12345-;rport Max-Forwards: 70 Contact: sip:303@192.168.1.240:5061 To: "301"sip:301@192.168.1.211:5060 From: "303"sip:303@192.168.1.211:5060;tag=28534e5fb94617fc Call-ID: 77eb3acc18bb92f7f6d Cseq: 1 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce/48.0 Content-Type: text/plain Content-Length: 15

TEST 10/11/2023

using "asterisk -rvvvvvvv"

[2023-11-10 12:22:58] ERROR[2433]: pjproject: <?>: sip_transport.c Error processing 498 bytes packet from UDP 192.168.1.240:5061 : PJSIP syntax error exception when parsing 'Request Line' header on line 1 col 34: MESSAGE im:301@192.168.1.211:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.240:5061;branch=z123456-y12345-11d9f2afba28ddf6-1--d12345-;rport Max-Forwards: 70 Contact: sip:303@192.168.1.240:5061 To: "301"sip:301@192.168.1.211:5060 From: "303"sip:303@192.168.1.211:5060;tag=28534e5fb94617fc Call-ID: 77eb3acc18bb92f7f6d Cseq: 1 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, REFER, NOTIFY, OPTIONS, MESSAGE User-Agent: JavaForce/48.0 Content-Type: text/plain Content-Length: 15

TEST 10/11/2023