JAVA/ connect time out with socket binding - java

Two parts:
InetAddress ia = Inet4Address.getByAddress(new byte[]{(byte)192,(byte)168,(byte)10,(byte)100});
Socket socket = new Socket();
InetSocketAddress isa = new InetSocketAddress("82.146.58.81", 5277);
socket.bind(new InetSocketAddress(ia, 0));
System.out.println("local_address:" + socket.getLocalSocketAddress());
socket.connect(isa, 1000);
Thread.sleep(1000);
socket.close();
System.out.println("done_1");
InetAddress ia_2 = Inet4Address.getByAddress(new byte[]{(byte)172,(byte)20,(byte)10,(byte)2});
Socket socket_2 = new Socket();
InetSocketAddress isa2 = new InetSocketAddress("82.146.58.81", 5277);
socket_2.bind(new InetSocketAddress(ia_2, 0));
System.out.println("local_address:" + socket_2.getLocalSocketAddress());
socket_2.connect(isa2, 30000);
Thread.sleep(1000);
socket_2.close();
System.out.println("done_2");
First part of code worked, second not - java.net.SocketTimeoutException: connect timed out.
I am trying to communicate with the host "82.146.58.81" through different interfaces.
But only the part that has the default route is successful. Why?
Update: I am worked by Ubuntu 17.10, seems the same problem in Armbian too. Problem not reproducible under Windows7
Update: Wrong OUT interface:
[12979.049742] IN= OUT=enp4s0 SRC=172.20.10.2 DST=82.146.58.81 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=25967 DF PROTO=TCP SPT=48985 DPT=5277 WINDOW=29200 RES=0x00 SYN URGP=0
kostas#work:~$ ifconfig
enp0s16f0u1c4i2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.10.2 netmask 255.255.255.240 broadcast 172.20.10.15
inet6 fe80::17c7:4582:897b:11d5 prefixlen 64 scopeid 0x20<link>
ether 86:38:35:c8:f5:39 txqueuelen 1000 (Ethernet)
RX packets 575 bytes 117085 (117.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 686 bytes 82681 (82.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.100 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::80b9:8cf3:92c6:4aef prefixlen 64 scopeid 0x20<link>
ether 00:e0:66:ae:2a:de txqueuelen 1000 (Ethernet)
RX packets 100455 bytes 65543315 (65.5 MB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 75513 bytes 15658830 (15.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
kostas#work:~$ route
Таблица маршутизации ядра протокола IP
Destination Gateway Genmask Flags Metric Ref Use Iface
default unknown 0.0.0.0 UG 100 0 0 enp4s0
default gateway 0.0.0.0 UG 101 0 0 enp0s16f0u1c4i2
kostas#work:~$ ping mail.ru -I enp0s16f0u1c4i2
PING mail.ru (217.69.139.202) from 172.20.10.2 enp0s16f0u1c4i2: 56(84) bytes of data.
64 bytes from mail.ru (217.69.139.202): icmp_seq=1 ttl=51 time=508 ms
64 bytes from mail.ru (217.69.139.202): icmp_seq=2 ttl=51 time=187 ms

"However, many OSes do not honour this "hint" and will use the routing table anyway."
Answer here

Related

HUAWEI Mate20 webrtc crash issue:Failed to set remote answer sdp: Failed to set remote video description send parameters

I'm working on adding native AWS webrtc for our Android hybrid App. It works well on other smartphones but will crash on HUAWEI. When the webrtc connection succeed, App crashed. Here is the part of the Log:
D/webRTC: sent sdp offer
D/KinesisVideoSdpObserver: onCreateSuccess(): SDP=v=0
o=- 4089128915904689992 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1 2
a=msid-semantic: WMS KvsLocalMediaStream
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:EmPX
a=ice-pwd:m5FQR9O6Gu+m0kQk8SFYXUg6
a=ice-options:trickle renomination
a=fingerprint:sha-256 71:6C:44:F7:66:58:E0:BE:C9:CB:0E:E7:54:0C:2A:05:9B:AC:B1:A8:27:60:CC:A4:CE:A7:50:D7:45:41:94:7E
a=setup:actpass
a=mid:0
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:13 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:12 urn:3gpp:video-orientation
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:KvsLocalMediaStream KvsVideoTrack
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 red/90000
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:127 ulpfec/90000
a=ssrc-group:FID 3389218480 1760322665
a=ssrc:3389218480 cname:oMzbiO27u3BctYUf
a=ssrc:3389218480 msid:KvsLocalMediaStream KvsVideoTrack
a=ssrc:3389218480 mslabel:KvsLocalMediaStream
a=ssrc:3389218480 label:KvsVideoTrack
a=ssrc:1760322665 cname:oMzbiO27u3BctYUf
a=ssrc:1760322665 msid:KvsLocalMediaStream KvsVideoTrack
a=ssrc:1760322665 mslabel:KvsLocalMediaStream
a=ssrc:1760322665 label:KvsVideoTrack
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:EmPX
a=ice-pwd:m5FQR9O6Gu+m0kQk8SFYXUg6
a=ice-options:trickle renomination
a=fingerprint:sha-256 71:6C:44:F7:66:58:E0:BE:C9:CB:0E:E7:54:0C:2A:05:9B:AC:B1:A8:27:60:CC:A4:CE:A7:50:D7:45:41:94:7E
a=setup:actpass
a=mid:1
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:EmPX
a=ice-pwd:m5FQR9O6Gu+m0kQk8SFYXUg6
a=ice-options:trickle renomination
a=fingerprint:sha-256 71:6C:44:F7:66:58:E0:BE:C9:CB:0E:E7:54:0C:2A:05:9B:AC:B1:A8:27:60:CC:A4:CE:A7:50:D7:45:41:94:7E
a=setup:actpass
a=mid:2
a=sctp-port:5000
a=max-message-size:262144
D/KVSPeerConnection: onSignalingChange(): signalingState = [HAVE_LOCAL_OFFER]
I/org.webrtc.Logging: NetworkMonitor: Start monitoring with native observer 502242368320
I/Liveview Success Time1: 1649211791701
D/WebSocketClient: isOpen true
D/SignalingServiceWebSocketClient: Sending Offer
D/KinesisVideoSdpObserver: onSetSuccess(): SDP
D/KVSPeerConnection: onIceGatheringChange(): iceGatheringState = [GATHERING]
I/ice: ================
D/KVSPeerConnection: onIceCandidate(): iceCandidate = [0:0:candidate:1114595702 1 udp 2122260223 192.168.0.110 37983 typ host generation 0 ufrag EmPX network-id 3 network-cost 10:]
D/KVSWebRtcActivity: Sending IceCandidate to remote peer 0:0:candidate:1114595702 1 udp 2122260223 192.168.0.110 37983 typ host generation 0 ufrag EmPX network-id 3 network-cost 10:
D/webRTC: send IceCandidate
D/SignalingServiceWebSocketClient: Sending JSON Message= xxxxxxx
D/SignalingServiceWebSocketClient: Sending JSON Message= xxxxxxx
Sent Ice candidate message
I/sent icecandidate time: 1649211791772
I/ice: ================
D/KVSPeerConnection: onIceCandidate(): iceCandidate = [0:0:candidate:842163049 1 udp 1686052607 223.112.52.222 37983 typ srflx raddr 192.168.0.110 rport 37983 generation 0 ufrag EmPX network-id 3 network-cost 10:stun:52.40.66.127:443]
D/KVSWebRtcActivity: Sending IceCandidate to remote peer 0:0:candidate:842163049 1 udp 1686052607 223.112.52.222 37983 typ srflx raddr 192.168.0.110 rport 37983 generation 0 ufrag EmPX network-id 3 network-cost 10:stun:52.40.66.127:443
D/webRTC: send IceCandidate
D/SignalingServiceWebSocketClient: Sending JSON Message= {"action":"ICE_CANDIDATE","messagePayload":"eyJjYW5kaWRhdGUiOiJjYW5kaWRhdGU6ODQyMTYzMDQ5IDEgdWRwIDE2ODYwNTI2MDcgMjIzLjExMi41Mi4yMjIgMzc5ODMgdHlwIHNyZmx4IHJhZGRyIDE5Mi4xNjguMC4xMTAgcnBvcnQgMzc5ODMgZ2VuZXJhdGlvbiAwIHVmcmFnIEVtUFggbmV0d29yay1pZCAzIG5ldHdvcmstY29zdCAxMCIsInNkcE1pZCI6IjAiLCJzZHBNTGluZUluZGV4IjowfQ","senderClientId":"f3338830-084f-4736-bb78-2f56cee638df"}
D/SignalingServiceWebSocketClient: Sent JSON Message= {"action":"ICE_CANDIDATE","messagePayload":"eyJjYW5kaWRhdGUiOiJjYW5kaWRhdGU6ODQyMTYzMDQ5IDEgdWRwIDE2ODYwNTI2MDcgMjIzLjExMi41Mi4yMjIgMzc5ODMgdHlwIHNyZmx4IHJhZGRyIDE5Mi4xNjguMC4xMTAgcnBvcnQgMzc5ODMgZ2VuZXJhdGlvbiAwIHVmcmFnIEVtUFggbmV0d29yay1pZCAzIG5ldHdvcmstY29zdCAxMCIsInNkcE1pZCI6IjAiLCJzZHBNTGluZUluZGV4IjowfQ","senderClientId":"f3338830-084f-4736-bb78-2f56cee638df"}
Sent Ice candidate message
I/sent icecandidate time: 1649211791991
D/Web Console: scroll refreshed
I/chromium: [INFO:CONSOLE(1)] "scroll refreshed", source:
D/CustomMessageHandler: Received message
D/CustomMessageHandler: Received message
D/CustomMessageHandler: Received message
I/org.webrtc.Logging: EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging: EglRenderer: Duration: 4008 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging: EglRenderer: Duration: 4010 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
D/CustomMessageHandler: Received message xxxxxx
D/CustomMessageHandler: Answer received: SenderClientId=null
D/KVSWebRtcActivity: SDP answer received from signaling
D/webRTC: SDP answer received from signaling
D/Event: SDP answer received from master:v=0
o=- 1008569513 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1 2
a=msid-semantic: WMS myKvsVideoStream
m=video 9 UDP/TLS/RTP/SAVPF 0
c=IN IP4 127.0.0.1
a=candidate:3 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:2 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:1 1 udp 1694498815 192.168.100.127 58511 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=candidate:0 1 udp 2130706431 192.168.100.127 49366 typ host raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=msid:myKvsVideoStream myVideoTrack
a=ssrc:1245743577 cname:4/iWRN2u/W8ElBZu
a=ssrc:1245743577 msid:myKvsVideoStream myVideoTrack
a=ssrc:1245743577 mslabel:myKvsVideoStream
a=ssrc:1245743577 label:myVideoTrack
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:RRgY
a=ice-pwd:TeUGFE3L9FpsBOW3dCZSIycZ
a=ice-options:trickle
a=fingerprint:sha-256 DC:C5:AE:21:EC:E8:40:70:05:7F:1A:07:5C:F1:FF:64:3F:1B:8D:9F:59:34:C9:7A:B8:F3:EB:BE:D9:68:92:26
a=setup:active
a=mid:0
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:0 H264/90000
a=rtcp-fb:0 nack
a=rtcp-fb:0 transport-cc
m=audio 9 UDP/TLS/RTP/SAVPF 0
c=IN IP4 127.0.0.1
a=candidate:3 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:2 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:1 1 udp 1694498815 192.168.100.127 58511 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=candidate:0 1 udp 2130706431 192.168.100.127 49366 typ host raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=msid:myKvsAudioStream myAudioTrack
a=ssrc:1029037518 cname:4/iWRN2u/W8ElBZu
a=ssrc:1029037518 msid:myKvsAudioStream myAudioTrack
a=ssrc:1029037518 mslabel:myKvsAudioStream
a=ssrc:1029037518 label:myAudioTrack
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:RRgY
a=ice-pwd:TeUGFE3L9FpsBOW3dCZSIycZ
a=ice-options:trickle
a=fingerprint:sha-256 DC:C5:AE:21:EC:E8:40:70:05:7F:1A:07:5C:F1:FF:64:3F:1B:8D:9F:59:34:C9:7A:B8:F3:EB:BE:D9:68:92:26
a=setup:active
a=mid:1
a=sendonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:0 PCMU/8000
a=rtcp-fb:0 nack
a=rtcp-fb:0 transport-cc
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 127.0.0.1
a=candidate:3 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:2 1 udp 16777215 0000:0000:0000:0000:0000:0000:0000:0000 0 typ relay raddr ::/0 rport 0 generation 0 network-cost 999
a=candidate:1 1 udp 1694498815 192.168.100.127 58511 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=candidate:0 1 udp 2130706431 192.168.100.127 49366 typ host raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:RRgY
a=ice-pwd:TeUGFE3L9FpsBOW3dCZSIycZ
a=fingerprint:sha-256 DC:C5:AE:21:EC:E8:40:70:05:7F:1A:07:5C:F1:FF:64:3F:1B:8D:9F:59:34:C9:7A:B8:F3:EB:BE:D9:68:92:26
a=setup:active
a=mid:2
a=sctp-port:5000
I/receive sdpanswer time: 1649211803034
D/KVSPeerConnection: onSignalingChange(): signalingState = [STABLE]
D/KVSWebRtcActivity: Answer Client ID: null
E/KinesisVideoSdpObserver: onSetFailure(): Error=Failed to set remote answer sdp: Failed to set remote video description send parameters.
D/KVSWebRtcActivity: Pending ice candidates found? null
D/CustomMessageHandler: Received message{"messagePayload":"eyJjYW5kaWRhdGUiOiJjYW5kaWRhdGU6MCAxIHVkcCAyMTMwNzA2NDMxIDE5Mi4xNjguMTAwLjEyNyA0OTM2NiB0eXAgaG9zdCByYWRkciAwLjAuMC4wIHJwb3J0IDAgZ2VuZXJhdGlvbiAwIG5ldHdvcmstY29zdCA5OTkiLCJzZHBNaWQiOiIwIiwic2RwTUxpbmVJbmRleCI6MH0=","messageType":"ICE_CANDIDATE"}
D/CustomMessageHandler: Ice Candidate received: SenderClientId=null
{"candidate":"candidate:0 1 udp 2130706431 192.168.100.127 49366 typ host raddr 0.0.0.0 rport 0 generation 0 network-cost 999","sdpMid":"0","sdpMLineIndex":0}
D/KVSWebRtcActivity: Received IceCandidate from remote
D/KVSWebRtcActivity: Peer connection found already
D/KVSPeerConnection: onIceConnectionChange(): iceConnectionState = [CHECKING]
D/KVSWebRtcActivity: Added ice candidate 0:0:candidate:0 1 udp 2130706431 192.168.100.127 49366 typ host raddr 0.0.0.0 rport 0 generation 0 network-cost 999: Successfully
D/CustomMessageHandler: Received message{"messagePayload":"eyJjYW5kaWRhdGUiOiJjYW5kaWRhdGU6MSAxIHVkcCAxNjk0NDk4ODE1IDIyMy4xMTIuNTIuMjIyIDU4NTExIHR5cCBzcmZseCByYWRkciAwLjAuMC4wIHJwb3J0IDAgZ2VuZXJhdGlvbiAwIG5ldHdvcmstY29zdCA5OTkiLCJzZHBNaWQiOiIwIiwic2RwTUxpbmVJbmRleCI6MH0=","messageType":"ICE_CANDIDATE"}
D/CustomMessageHandler: Ice Candidate received: SenderClientId=null
D/CustomMessageHandler: {"candidate":"candidate:1 1 udp 1694498815 223.112.52.222 58511 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999","sdpMid":"0","sdpMLineIndex":0}
D/KVSWebRtcActivity: Received IceCandidate from remote
D/KVSWebRtcActivity: Peer connection found already
D/KVSWebRtcActivity: Added ice candidate 0:0:candidate:1 1 udp 1694498815 223.112.52.222 58511 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999: Successfully
D/KVSPeerConnection: onIceConnectionChange(): iceConnectionState = [CONNECTED]
I/org.webrtc.Logging: WebRtcAudioTrackExternal: initPlayout(sampleRate=48000, channels=1)
I/org.webrtc.Logging: WebRtcAudioTrackExternal: byteBuffer.capacity: 960
I/org.webrtc.Logging: WebRtcAudioTrackExternal: AudioTrack.getMinBufferSize: 3848
WebRtcAudioTrackExternal: createAudioTrackOnLollipopOrHigher
I/org.webrtc.Logging: WebRtcAudioTrackExternal: nativeOutputSampleRate: 48000
I/AudioTrack-JNI: AudioTrack_setup for usage=2 content=1 flags=0x0x800 tags=
I/org.webrtc.Logging: WebRtcAudioTrackExternal: AudioTrack: session ID: 305, channels: 1, sample rate: 48000, max gain: 1.0
I/org.webrtc.Logging: WebRtcAudioTrackExternal: AudioTrack: buffer size in frames: 3848
WebRtcAudioTrackExternal: AudioTrack: buffer capacity in frames: 3848
I/org.webrtc.Logging: VolumeLogger: start#[name=worker_thread - 23606, id=18331]
V/AudioManager: getMode...
I/org.webrtc.Logging: VolumeLogger: audio mode is: MODE_NORMAL
V/AudioManager: getStreamMaxVolume treamType: 2
getStreamMaxVolume treamType: 0
V/AudioManager: getMode...
I/org.webrtc.Logging: WebRtcAudioTrackExternal: startPlayout
V/PlayerBase: baseStart() piid=391
D/android.media.AudioTrack: [HSM] AudioTrace play() uid: 10240, pid: 22933
I/org.webrtc.Logging: WebRtcAudioTrackExternal: AudioTrackThread#[name=AudioTrackJavaThread, id=18345]
D/CustomMessageHandler: Received message{"messagePayload":"eyJjYW5kaWRhdGUiOiJjYW5kaWRhdGU6MiAxIHVkcCAxNjc3NzIxNSAxOC4yMzYuMTYyLjE0NSA1ODUyOSB0eXAgcmVsYXkgcmFkZHIgMC4wLjAuMCBycG9ydCAwIGdlbmVyYXRpb24gMCBuZXR3b3JrLWNvc3QgOTk5Iiwic2RwTWlkIjoiMCIsInNkcE1MaW5lSW5kZXgiOjB9","messageType":"ICE_CANDIDATE"}
Ice Candidate received: SenderClientId=null
D/CustomMessageHandler: {"candidate":"candidate:2 1 udp 16777215 18.236.162.145 58529 typ relay raddr 0.0.0.0 rport 0 generation 0 network-cost 999","sdpMid":"0","sdpMLineIndex":0}
D/KVSWebRtcActivity: Received IceCandidate from remote
D/KVSWebRtcActivity: Peer connection found already
D/KVSWebRtcActivity: Added ice candidate 0:0:candidate:2 1 udp 16777215 18.236.162.145 58529 typ relay raddr 0.0.0.0 rport 0 generation 0 network-cost 999: Successfully
A/m.sercomm.s1ap: thread-inl.h:269] Transitioning to runnable with checkpoint flag, flags=58403 state=2
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x753b600000 in tid 23629 (AudioTrackJavaT), pid 22933 (m.sercomm.s1app)
E/RtgSchedManager: endActivityTransaction: margin state not match
Disconnected from the target VM, address: 'localhost:53093', transport: 'socket'
The main error Info is:
E/KinesisVideoSdpObserver: onSetFailure(): Error=Failed to set remote answer sdp: Failed to set remote video description send parameters.
What I'm confused is that in sdp offer, the codec be like:
a=rtpmap:98 VP9/90000
But in sdp answer I found:
a=rtpmap:0 H264/90000
Is this the main cause of the crash? On other smartphone(I tried Xiaomi, Samsung, Vivo),this two sdp lines are both H264. But HUAWEI do support H264, this is my HUAWEI Mate 20 codecInfo:
E/MediaCodecList, name:: c2.android.aac.decoder,type:audio/mp4a-latm
OMX.google.aac.decoder,type:audio/mp4a-latm
c2.android.aac.encoder,type:audio/mp4a-latm
OMX.google.aac.encoder,type:audio/mp4a-latm
c2.android.amrnb.decoder,type:audio/3gpp
E/MediaCodecList, name:: OMX.google.amrnb.decoder,type:audio/3gpp
c2.android.amrnb.encoder,type:audio/3gpp
OMX.google.amrnb.encoder,type:audio/3gpp
c2.android.amrwb.decoder,type:audio/amr-wb
OMX.google.amrwb.decoder,type:audio/amr-wb
c2.android.amrwb.encoder,type:audio/amr-wb
OMX.google.amrwb.encoder,type:audio/amr-wb
c2.android.flac.decoder,type:audio/flac
OMX.google.flac.decoder,type:audio/flac
c2.android.flac.encoder,type:audio/flac
OMX.google.flac.encoder,type:audio/flac
c2.android.g711.alaw.decoder,type:audio/g711-alaw
OMX.google.g711.alaw.decoder,type:audio/g711-alaw
c2.android.g711.mlaw.decoder,type:audio/g711-mlaw
OMX.google.g711.mlaw.decoder,type:audio/g711-mlaw
c2.android.gsm.decoder,type:audio/gsm
E/MediaCodecList, name:: OMX.google.gsm.decoder,type:audio/gsm
c2.android.mp3.decoder,type:audio/mpeg
OMX.google.mp3.decoder,type:audio/mpeg
c2.android.opus.decoder,type:audio/opus
OMX.google.opus.decoder,type:audio/opus
c2.android.opus.encoder,type:audio/opus
c2.android.raw.decoder,type:audio/raw
OMX.google.raw.decoder,type:audio/raw
c2.android.vorbis.decoder,type:audio/vorbis
OMX.google.vorbis.decoder,type:audio/vorbis
OMX.dolby.ac3.decoder,type:audio/ac3
OMX.dolby.ac4.decoder,type:audio/ac4
OMX.dolby.eac3.decoder,type:audio/eac3
OMX.dolby.eac3_joc.decoder,type:audio/eac3-joc
OMX.hisi.video.decoder.avc,type:video/avc
OMX.hisi.video.decoder.hevc,type:video/hevc
OMX.hisi.video.decoder.mpeg2,type:video/mpeg2
OMX.hisi.video.decoder.mpeg4,type:video/mp4v-es
OMX.hisi.video.decoder.vp8,type:video/x-vnd.on2.vp8
OMX.hisi.video.decoder.vp9,type:video/x-vnd.on2.vp9
E/MediaCodecList, name:: OMX.hisi.video.encoder.avc,type:video/avc
OMX.hisi.video.encoder.hevc,type:video/hevc
c2.android.av1.decoder,type:video/av01
c2.android.avc.decoder,type:video/avc
OMX.google.h264.decoder,type:video/avc
c2.android.avc.encoder,type:video/avc
OMX.google.h264.encoder,type:video/avc
c2.android.h263.decoder,type:video/3gpp
OMX.google.h263.decoder,type:video/3gpp
c2.android.h263.encoder,type:video/3gpp
OMX.google.h263.encoder,type:video/3gpp
c2.android.hevc.decoder,type:video/hevc
OMX.google.hevc.decoder,type:video/hevc
c2.android.hevc.encoder,type:video/hevc
c2.android.mpeg4.decoder,type:video/mp4v-es
OMX.google.mpeg4.decoder,type:video/mp4v-es
c2.android.mpeg4.encoder,type:video/mp4v-es
OMX.google.mpeg4.encoder,type:video/mp4v-es
c2.android.vp8.decoder,type:video/x-vnd.on2.vp8
E/MediaCodecList, name:: OMX.google.vp8.decoder,type:video/x-vnd.on2.vp8
c2.android.vp8.encoder,type:video/x-vnd.on2.vp8
OMX.google.vp8.encoder,type:video/x-vnd.on2.vp8
c2.android.vp9.decoder,type:video/x-vnd.on2.vp9
OMX.google.vp9.decoder,type:video/x-vnd.on2.vp9
c2.android.vp9.encoder,type:video/x-vnd.on2.vp9
OMX.google.vp9.encoder,type:video/x-vnd.on2.vp9
And I also try to read webrtc code, I found this in MediaCodecVideoDecoderFactory:
private boolean isH264HighProfileSupported(MediaCodecInfo info) {
String name = info.getName();
if (VERSION.SDK_INT >= 21 && name.startsWith("OMX.qcom.")) {
return true;
} else {
return VERSION.SDK_INT >= 23 && name.startsWith("OMX.Exynos.");
}
}
I doubt webrtc did not support codec like OMX.google.xxxxx . But I can't modify this code, how can I modify it so I can have a verification.
By the way, this is my webrtc implementation in gradle, if it helps:
implementation 'org.webrtc:google-webrtc:1.0.28513'
The AWS webrtc code is from AWS webrtc demo App, you can get here:awswebrtcdemoapp
And I'm sorry I can not offer my source code.
WebRTC Android only support qcom and Exynos hardware H264 encoders, you can change isHardwareSupportedInCurrentSdkH264 in HardwareVideoEncoderFactory to support other platforms such as OMX.hisi, OMX.MTK.
And then build the WebRTC to use libwebrtc.jar and libjingle_peerconnection_so.so in your project instead of
implementation 'org.webrtc:google-webrtc:1.0.28513'
how to download and build WebRTC Android:
https://webrtc.github.io/webrtc-org/native-code/android/

Get specific small string from a bigger one with multiple occurences

I made an android application that returns to the console some Linux commands.
In this case I want to find my wlan0 ip and my wlan1(when is connected) ip.
I've got the full text returned by ifconfig command. The problem is how can get into 2 variables these 2 IPs?
I Tried to substring after inet word but there are more than 1 word with inet. What is the optimal solution for this?
This is my string :
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 37 bytes 7123 (6.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 37 bytes 7123 (6.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
p2p0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet6 xxxxxx prefixlen 64 scopeid 0x20<link>
ether xxxxxx txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 xxxxxxxxxxx prefixlen 64 scopeid 0x20<link>
ether xxxxxxx6 txqueuelen 1000 (Ethernet)
RX packets 1504 bytes 817297 (798.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 686 bytes 126080 (123.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Please note that I don't care about :p2p0 or lo section, only wlan0 and wlan1(when is connected).
What I want is to save 192.168.0.100 into a String ip;
Thanks in advance!
I am not sure if i understood what you trying but i think Regular Expressions
is a possible way to go

udp socket receive buffer size

I am use Netty ( a java network framework) to server UDP request .
I found the
SO_RCVBUF
and
/proc/sys/net/core/rmem_default
and
/proc/net/udp
output confusing:
By the manual of socket( man 7 socket) It explains :
rmem_default
contains the default setting in bytes of the socket receive
buffer.
rmem_max
contains the maximum socket receive buffer size in bytes which
a user may set by using the SO_RCVBUF socket option.
and the /proc/net/udp show's the udp receive queue size :
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
60: 00000000:2F3C 00000000:0000 07 00000000:0003E094 00:00000000 00000000 500 0 2224362 2 ffff810066908cc0
I can get the SO_RCVBUF = 12904, but the rx_queue size is 254100(3E094), and rmem_default is 262142
my confuse is, why the SO_RCVBUF not equals to the rmem_default, and why the queue size not equals the SO_RCVBUF (but larger than it ) ?
It seams the ctx.channel().config().getOption(ChannelOption.SO_RCVBUF)'s value is half of /proc/sys/net/core/rmem_default and the real receive buffer size( queue size ) is also the value of /proc/sys/net/core/rmem_default
so why ctx.channel().config().getOption(ChannelOption.SO_RCVBUF) not equals to the system's config ?
The accepted answer is wrong. The correct alignment is:
tx_queue rx_queue
00000000:0003E094
So rx_queue is 0x0003E094 or 254100. This can be confirmed using netstat -unlp | grep pid , Recv-Q is second column. Example output:
cat /proc/net/udp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops
8101: 41FD080A:06A5 00000000:0000 07 00000000:00005A00 00:00000000 00000000 1000 0 3892411 2 0000000000000000 0
netstat --udp -nl
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 23040 0 10.8.253.65:1701 0.0.0.0:*
Here, 0x00005A00==23040
You seem to have misread the output. When you line up the columns properly, rx_queue is zero.

Socket Channel - readIntoNativeBuffer() Error

I have been experiencing this issue for a while now. A quick explanation of the system:
A simple application will read in data over a tcp connection. The application uses Socketchannel object to establish a data communication line. The connection to hardware is established, and the application processes roughly between 400 - 700 packets before throwing the error:
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218)
at sun.nio.ch.IOUtil.read(IOUtil.java:186)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359)
I suspect it has to do with the operating system (windows 7) buffer, although I have tried a few work arounds (increasing JVM heap size, and creating additional registry variables for TCP settings), but with no luck.
Inspecting packet data using wireshark, the following information can been seen just as the error occurs
[TCP Window Full] 5001 > 49995 [PSH, ACK] Seq=123177 Ack=1 Win=200 Len=176
[TCP ZeroWindow] 49995 > 5001 [ACK] Seq=1 Ack=123353 Win=0 Len=0
Which is then followed by a series of
[TCP Dup ACK 144#1] 5001 > 49995 [ACK] Seq=123353 Ack=1 Win=200 Len=0
until the connection is terminated.
I am hoping perhaps someone has had a similar issue in the past,or could offer some guidance on something I may be overlooking.
Here is sample code where data is read, and the error is thrown.
try{
do{
socketChannel.read(syncBuf);
start = syncBuf.get(0);
int b = start;
System.out.println("start byte is " + b);
syncBuf.clear();
}while(start != INIT_BYTE);
}catch(Exception e){
e.printStackTrace();
}
packetBuf.order(ByteOrder.LITTLE_ENDIAN);
packetBuf.clear();
try{
while(socketChannel.read(packetBuf) != 206){
nrBytesRead += socketChannel.read(packetBuf);
}
}catch(Exception e){
ApplicationLogger.log("Error at INIT_BYTE loop ", "ERROR");
}
Many thanks.
I think you have a problem here:
while(socketChannel.read(packetBuf) != 206)
{
nrBytesRead += socketChannel.read(packetBuf);
}
socketChannel.read(packetBuf) will return the number read this time, not the total, and I guess that's what 206 is, the total read.
You probably want to do that:
do
{
nrBytesRead += socketChannel.read(packetBuf);
}
while (nrBytesRead != 206)

Java SocketException Maximum number of datagram sockets reached

I have a java app program run on centos 6.3 and tomcat 7 as the app container, currently I meet one error : java.io.socketexception Maximum number of datagram sockets reached
we use MulticastSocket class to send message. when this error happened, I check the current server UDP socket count with command: ss -s
Total: 212 (kernel 248)
TCP: 70 (estab 15, closed 44, orphaned 0, synrecv 0, timewait 40/0), ports 22
Transport Total IP IPv6
* 248 - -
RAW 0 0 0
UDP 40 40 0
TCP 26 26 0
INET 66 66 0
FRAG 0 0 0
and I also check the
ulimits -n
The default setting is 32768, seem UDP socket count not exceed max count.
Any ideas for this error?
we use MulticastSocket class to send message.
Why? You only need a MulticastSocket to receive multicasts.
Obviously you are leaking MulticastSockets. Presumably you are creating a new one per message and never closing it.

Categories

Resources