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

Successful TCP socket connection refactor #406

Closed
mikaelwills opened this issue Sep 28, 2023 · 7 comments
Closed

Successful TCP socket connection refactor #406

mikaelwills opened this issue Sep 28, 2023 · 7 comments

Comments

@mikaelwills
Copy link
Contributor

Hey guys,

For a work research project we needed a flutter client to connect and use a 3cx server.
3cx unfortunately doesn't allow for a websocket connection.

I've succefully implemented a TCP connection with this package by abstracting a SocketInterface class that two WebSocket, and TcpSocket classes extend. Can register with the 3CX server, make calls, talk successfully and hang up.

I'm reaching out to field the interest in this as a future pull request!

Cheers

@mikaelwills mikaelwills changed the title TCP Socket connection Successful TCP socket connection refactor Sep 28, 2023
@BarakatMohamad
Copy link

@mikaelwills how you do that please ?

@BarakatMohamad
Copy link

Hey guys,

For a work research project we needed a flutter client to connect and use a 3cx server. 3cx unfortunately doesn't allow for a websocket connection.

I've succefully implemented a TCP connection with this package by abstracting a SocketInterface class that two WebSocket, and TcpSocket classes extend. Can register with the 3CX server, make calls, talk successfully and hang up.

I'm reaching out to field the interest in this as a future pull request!

Cheers

@mikaelwills how you do that please ?

@mikaelwills
Copy link
Contributor Author

@mikaelwills how you do that please ?

Its all in the example app now, call the SIPUAHelper's start() function wih TransportType.TCP in your settings transport type.

@BarakatMohamad
Copy link

BarakatMohamad commented Sep 24, 2024

@mikaelwills I do that and I registered correctly but when I make the call show me this : [2024-09-24 14:13:35.448] Level.debug socket_transport.dart:128 ::: Socket Transport send()
I/flutter ( 8410): [2024-09-24 14:13:35.451] Level.debug tcp_socket.dart:134 ::: send()
I/flutter ( 8410): [2024-09-24 14:13:35.454] Level.debug digest_authentication.dart:198 ::: authenticate() | using qop=null [a2:INVITE:sip:0580224645@sip.wasel.sa]
I/flutter ( 8410): [2024-09-24 14:13:35.457] Level.debug digest_authentication.dart:204 ::: authenticate() | response generated
I/flutter ( 8410): [2024-09-24 14:13:35.463] Level.debug socket_transport.dart:128 ::: Socket Transport send()
I/flutter ( 8410): [2024-09-24 14:13:35.466] Level.debug sip_message.dart:276 ::: Outgoing Message: SipMethod.INVITE body: v=0
I/flutter ( 8410): o=- 7702495247213080239 2 IN IP4 127.0.0.1
I/flutter ( 8410): s=-
I/flutter ( 8410): t=0 0
I/flutter ( 8410): a=group:BUNDLE 0
I/flutter ( 8410): a=extmap-allow-mixed
I/flutter ( 8410): a=msid-semantic: WMS 7c20fe18-10d0-4bbf-873b-df4a59a50521
I/flutter ( 8410): m=audio 63137 UDP/TLS/RTP/SAVPF 111 63 9 102 0 8 13 110 126
I/flutter ( 8410): c=IN IP4 38.123.109.218
I/flutter ( 8410): a=rtcp:9 IN IP4 0.0.0.0
I/flutter ( 8410): a=candidate:3386182543 1 udp 2122194687 26.26.26.1 39104 typ host generation 0 network-id 3 network-cost 10
I/flutter ( 8410): a=candidate:2744280504 1 udp 2122063615 127.0.0.1 40403 typ host generation 0 network-id 1
I/flutter ( 8410): a=candidate:366230917 1 udp 2122136831 ::1 38052 typ host generation 0 network-id 2
I/flutter ( 8410): a=candidate:2945919384 1 tcp 1518280447 192.168.88.190 9 typ host tcptype active generation 0 network-id 4 network-cost 10
I/flutter ( 8410): a=candidate:3713894176 1 tcp 1518083839 127.0.0.1 44769 typ host tcptype passive generation 0 network-id 1
I/flutter ( 8410): a=candidate:1796988701 1 tcp 1518157055 ::1 42788 typ host tcptype passive generation 0 network-id 2
I/flutter ( 8410): a=candidate:1707601643 1 udp
I/flutter ( 8410): [2024-09-24 14:13:35.467] Level.debug tcp_socket.dart:134 ::: send()
I/flutter ( 8410): [2024-09-24 14:13:35.470] Level.debug invite_client.dart:90 ::: Timer D expired for transaction z9hG4bK3112500610000000
I/flutter ( 8410): [2024-09-24 14:13:35.473] Level.debug tcp_socket_impl.dart:62 ::: send:
I/flutter ( 8410):
I/flutter ( 8410): ACK sip:0580224645@sip.wasel.sa SIP/2.0
I/flutter ( 8410): Via: SIP/2.0/TCP sip.wasel.sa;branch=z9hG4bK3112500610000000
I/flutter ( 8410): Max-Forwards: 69
I/flutter ( 8410): To: sip:0580224645@sip.wasel.sa;tag=as232b6818
I/flutter ( 8410): From: "Flutter SIP UA" sip:302@sip.wasel.sa;tag=tjpzjvgb0t
I/flutter ( 8410): Call-ID: 82278ahqio7m5pngitwk
I/flutter ( 8410): CSeq: 2879 ACK
I/flutter ( 8410): Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
I/flutter ( 8410): Supported: outbound
I/flutter ( 8410): User-Agent: Dart SIP Client v2.0.0
I/flutter ( 8410): Content-Length: 0
I/flutter ( 8410):
I/flutter ( 8410): [2024-09-24 14:13:35.477] Level.debug tcp_socket_impl.dart:62 ::: send:
I/flutter ( 8410):
I/flutter ( 8410): INVITE sip:0580224645@sip.wasel.sa SIP/2.0
I/flutter ( 8410): Via: SIP/2.0/TCP sip.wasel.sa;branch=z9hG4bK13304381280000000
I/flutter ( 8410): Max-Forwards: 69
I/flutter ( 8410): To: sip:0580224645@sip.wasel.sa
I/flutter ( 8410): From: "Flutter SIP UA" sip:302@sip.wasel.sa;tag=tjpzjvgb0t
I/flutter ( 8410): Call-ID: 82278ahqio7m5pngitwk
I/flutter ( 8410): CSeq: 2880 INVITE
I/flutter ( 8410): Authorization: Digest algorithm=MD5, username="302", realm="asterisk", nonce="0d396750", uri="sip:0580224645@sip.wasel.sa", response="3cead5c5c722034cc5811de85eba2991"
I/flutter ( 8410): X-Foo: foo
I/flutter ( 8410): X-Bar: bar
I/flutter ( 8410): X-Codec: Opus, PCMU
I/flutter ( 8410): Contact: sip:sip@sip.wasel.sa;ob
I/flutter ( 8410): Content-Type: application/sdp
I/flutter ( 8410): Session-Expires: 120
I/flutter ( 8410): Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
I/flutter ( 8410): Supported: timer,ice,replaces,outbound
I/flutter ( 8410): User-Agent: Dart SIP Client v2.0.0
I/flutter ( 8410): Content-Length: 2096
I/flutter ( 8410):
I/flutter ( 8410): v=0
I/flutter ( 8410): o=- 7702495247213080239 2 IN IP4 127.0.0.1
I/flutter ( 8410): s=-
I/flutter ( 8410): t=0 0
I/flutter ( 8410): a=group:BUNDLE 0
I/flutter ( 8410): a=extmap-allow-mixed
I/flutter ( 8410): a=msid-semantic: WMS 7c20fe18-10d0-4bbf-873b-df4a59a50521
I/flutter ( 8410): m=audio 63137 UDP/TLS/RTP/SAVPF 111 63 9 10
I/flutter ( 8410): [2024-09-24 14:13:35.567] Level.debug tcp_socket.dart:167 ::: Received TcpSocket data
I/flutter ( 8410): [2024-09-24 14:13:35.570] Level.debug socket_transport.dart:273 ::: received binary message:
I/flutter ( 8410):
I/flutter ( 8410): SIP/2.0 488 Not acceptable here
I/flutter ( 8410): Via: SIP/2.0/TCP sip.wasel.sa;branch=z9hG4bK13304381280000000;received=38.123.109.218;rport=16938
I/flutter ( 8410): From: "Flutter SIP UA" sip:302@sip.wasel.sa;tag=tjpzjvgb0t
I/flutter ( 8410): To: sip:0580224645@sip.wasel.sa;tag=as232b6818
I/flutter ( 8410): Call-ID: 82278ahqio7m5pngitwk
I/flutter ( 8410): CSeq: 2880 INVITE
I/flutter ( 8410): Server: Asterisk PBX 20.6.0~dfsg+~cs6.13.40431414-2build5
I/flutter ( 8410): Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
I/flutter ( 8410): Supported: replaces, timer
I/flutter ( 8410): Content-Length: 0
I/flutter ( 8410):
I/flutter ( 8410):
I/flutter ( 8410): [2024-09-24 14:13:35.585] Level.debug socket_transport.dart:128 ::: Socket Transport send()
I/flutter ( 8410): [2024-09-24 14:13:35.588] Level.debug tcp_socket.dart:134 ::: send()
I/flutter ( 8410): [2024-09-24 14:13:35.599] Level.debug rtc_session.dart:2397 ::: receiveInviteResponse() current status: 1
I/flutter ( 8410): [2024-09-24 14:13:35.608] Level.debug rtc_session.dart:3143 ::: session failed
I/flutter ( 8410): [2024-09-24 14:13:35.611] Level.debug rtc_session.dart:3146 ::: emit "_failed"
I/flutter ( 8410): [2024-09-24 14:13:35.616] Level.debug rtc_session.dart:1484 ::: close()
I/flutter ( 8410): [2024-09-24 14:13:35.619] Level.debug rtc_session.dart:3157 ::: emit "failed"
I/flutter ( 8410): [2024-09-24 14:13:35.623] Level.debug sip_ua_helper.dart:344 ::: call failed with cause: Code: [488], Cause: Incompatible SDP, Reason: Not acceptable here
D/FlutterWebRTCPlugin( 8410): onConnectionChangeCLOSED
I/flutter ( 8410): [2024-09-24 14:13:35.631] Level.debug invite_client.dart:90 ::: Timer D expired for transaction z9hG4bK13304381280000000
I/org.webrtc.Logging( 8410): NetworkMonitor: Stop monitoring with native observer 482578607968
I/org.webrtc.Logging( 8410): NetworkMonitorAutoDetect: Unregister network callback
I/flutter ( 8410): [2024-09-24 14:13:35.634] Level.debug tcp_socket_impl.dart:62 ::: send:
I/flutter ( 8410):
I/flutter ( 8410): ACK sip:0580224645@sip.wasel.sa SIP/2.0
I/flutter ( 8410): Via: SIP/2.0/TCP sip.wasel.sa;branch=z9hG4bK13304381280000000
I/flutter ( 8410): Max-Forwards: 69
I/flutter ( 8410): To: sip:0580224645@sip.wasel.sa;tag=as232b6818
I/flutter ( 8410): From: "Flutter SIP UA" sip:302@sip.wasel.sa;tag=tjpzjvgb0t
I/flutter ( 8410): Call-ID: 82278ahqio7m5pngitwk
I/flutter ( 8410): CSeq: 2880 ACK
I/flutter ( 8410): Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
I/flutter ( 8410): Supported: outbound
I/flutter ( 8410): User-Agent: Dart SIP Client v2.0.0
I/flutter ( 8410): Content-Length: 0
I/flutter ( 8410):
I/org.webrtc.Logging( 8410): NetworkMonitorAutoDetect: Unregister network callback
D/AudioManager( 8410): setSpeakerphoneOn false
D/AudioManager( 8410): java.lang.Throwable
D/AudioManager( 8410): at android.media.AudioManager.setSpeakerphoneOn(AudioManager.java:1265)
D/AudioManager( 8410): at com.twilio.audioswitch.AudioDeviceManager.enableSpeakerphone(AudioDeviceManager.kt:96)
D/AudioManager( 8410): at com.twilio.audioswitch.AudioDeviceManager.restoreAudioState(AudioDeviceManager.kt:114)
D/AudioManager( 8410): at com.twilio.audioswitch.AbstractAudioSwitch.deactivate(AbstractAudioSwitch.kt:309)
D/AudioManager( 8410): at com.cloudwebrtc.webrtc.audio.AudioSwitchManager.lambda$stop$4$com-cloudwebrtc-webrtc-audio-AudioSwitchManager(AudioSwitchManager.java:175)
D/AudioManager( 8410): at com.cloudwebrtc.webrtc.audio.AudioSwitchManager$$ExternalSyntheticLambda6.run(Unknown Source:2)
D/AudioManager( 8410): at android.os.Handler.handleCallback(Handler.java:794)
D/AudioManager( 8410): at android.os.Handler.dispatchMessage(Handler.java:99)
D/AudioManager( 8410): at android.os.Looper.loop(Looper.java:176)
D/AudioManager( 8410): at android.app.ActivityThread.main(ActivityThread.java:6635)
D/AudioManager( 8410): at java.lang.reflect.Method.invoke(Native Method)
D/AudioManager( 8410): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
D/AudioManager( 8410): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_AVAILABLE message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_AVAILABLE message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_CAP_CHANGED message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_IP_CHANGED message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_PRECHECK message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_CAP_CHANGED message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_IP_CHANGED message
W/ConnectivityManager.CallbackHandler( 8410): callback not found for CALLBACK_PRECHECK message
I/org.webrtc.Logging( 8410): EglRenderer: Releasing.
I/org.webrtc.Logging( 8410): EglRenderer: eglBase detach and release.
I/org.webrtc.Logging( 8410): EglRenderer: Releasing done.
I/org.webrtc.Logging( 8410): EglRenderer: Quitting render thread.
I/org.webrtc.Logging( 8410): EglRenderer: Releasing.
I/org.webrtc.Logging( 8410): EglRenderer: eglBase detach and release.
I/org.webrtc.Logging( 8410): EglRenderer: Releasing done.
I/org.webrtc.Logging( 8410): EglRenderer: Quitting render thread.

@mikaelwills
Copy link
Contributor Author

SIP/2.0 488 Not acceptable here

What PBX server are you using? If its 3cx make sure you un-tick 'block remote non-tunnel connections' in each user.

But overall there could be many reasons why the server has said this, might not like the encryption used, if you're trying to use DTLS SRTP inside the SDP or not, or if the codecs used in the SDP aren't supported by the server.

@BarakatMohamad
Copy link

-Server Domain (default server): [sip.wasel.sa]
-SIP Signaling Port: 5060 (TCP) .
-Protocol: We use TCP for SIP signaling.
Supported Codecs:
- We support G.711 (a-law and u-law) and G.729.
- Preferred Codec Order: G.711 > G.729 .
this is the server informations how I can change the codecs for this in the sip_ua code my account make the register but when I make the call show me that error can you help me please ?
@mikaelwills

@BarakatMohamad
Copy link

when I download another app and register in the same account then I make that call correctly but in the sip_ua example can not do the call @mikaelwills

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants