flutter_socket_io
flutter_socket_io copied to clipboard
socket.on('event',(data)) in iOS not working as expected.
Describe the bug I am connecting to proxy url of mine, after that I emmit certain event which goes through and callback comes to socket.on, Nothing is exectuted besides print statement in socket.on on ios whereas on android it works as expected.
socket.on(AppConstants.AUTH_EVENT, (data) {
print('Auth data ${data.toString()}');
parseAuthMessage(data, withRefreshToken);
});
Expected behavior Should exectute whatever there in socket.on Device details:
- Device: iphoneX
- OS: 12.2
- Package Version ^0.3.4
Relevant Logs I am not sure if below log will help you.
2019-08-29 18:54:38.453547+0530 Runner[5390:1151782] LOG SocketEngine: Got message: 3probe
2019-08-29 18:54:38.453774+0530 Runner[5390:1151782] LOG SocketEngine: Received probe response, should upgrade to WebSockets
2019-08-29 18:54:38.453891+0530 Runner[5390:1151782] LOG SocketEngine: Upgrading transport to WebSockets
2019-08-29 18:54:38.454000+0530 Runner[5390:1151782] LOG SocketEnginePolling: Sending poll: as type: 6
2019-08-29 18:54:38.454316+0530 Runner[5390:1151782] LOG SocketEnginePolling: Created POST string: 1:6
2019-08-29 18:54:38.454905+0530 Runner[5390:1151782] LOG SocketEnginePolling: POSTing
2019-08-29 18:54:38.455229+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: pong with data: []
2019-08-29 18:54:38.557283+0530 Runner[5390:1151782] LOG SocketEnginePolling: Got polling response
2019-08-29 18:54:38.557482+0530 Runner[5390:1151782] LOG SocketEnginePolling: Got poll message: 1:6
2019-08-29 18:54:38.557671+0530 Runner[5390:1151782] LOG SocketEngine: Got message: 6
2019-08-29 18:54:38.557801+0530 Runner[5390:1151782] LOG SocketEngine: Switching to WebSockets
2019-08-29 18:54:38.557991+0530 Runner[5390:1151782] LOG SocketEngineWebSocket: Sending ws: as type: 5
2019-08-29 18:54:38.558256+0530 Runner[5390:1151782] LOG SocketEngine: Flushing probe wait
2019-08-29 18:55:04.644786+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: ping with data: []
2019-08-29 18:55:04.644786+0530 Runner[5390:1152072] LOG SocketEngine: Writing ws: has data: false
2019-08-29 18:55:04.645093+0530 Runner[5390:1152072] LOG SocketEngineWebSocket: Sending ws: as type: 2
2019-08-29 18:55:04.844929+0530 Runner[5390:1151872] LOG SocketEngine: Got message: 3
2019-08-29 18:55:04.845375+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: pong with data: []
2019-08-29 18:55:31.833591+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: ping with data: []
2019-08-29 18:55:31.833591+0530 Runner[5390:1152200] LOG SocketEngine: Writing ws: has data: false
2019-08-29 18:55:31.833878+0530 Runner[5390:1152200] LOG SocketEngineWebSocket: Sending ws: as type: 2
2019-08-29 18:55:31.978228+0530 Runner[5390:1152200] LOG SocketEngine: Got message: 3
2019-08-29 18:55:31.978687+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: pong with data: []
2019-08-29 18:55:38.799904+0530 Runner[5390:1152200] TIC Read Status [1:0x281aacfc0]: 1:57
2019-08-29 18:55:38.800134+0530 Runner[5390:1152200] TIC Read Status [1:0x281aacfc0]: 1:57
2019-08-29 18:55:38.800215+0530 Runner[5390:1152200] TIC Read Status [1:0x281aacfc0]: 1:57
2019-08-29 18:55:38.802827+0530 Runner[5390:1152200] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x119d748d0] get output frames failed, state 8196
2019-08-29 18:55:38.803135+0530 Runner[5390:1152200] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x119d748d0] get output frames failed, state 8196
2019-08-29 18:55:38.804129+0530 Runner[5390:1152200] TIC Read Status [1:0x0]: 1:57
2019-08-29 18:55:38.804192+0530 Runner[5390:1152200] TIC Read Status [1:0x0]: 1:57
2019-08-29 18:55:38.804237+0530 Runner[5390:1152200] TIC Read Status [1:0x0]: 1:57
2019-08-29 18:55:38.804281+0530 Runner[5390:1152200] TIC Read Status [1:0x0]: 1:57
2019-08-29 18:55:59.146971+0530 Runner[5390:1152303] LOG SocketEngine: Writing ws: has data: false
2019-08-29 18:55:59.146971+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: ping with data: []
2019-08-29 18:55:59.147239+0530 Runner[5390:1152303] LOG SocketEngineWebSocket: Sending ws: as type: 2
2019-08-29 18:55:59.389182+0530 Runner[5390:1152200] LOG SocketEngine: Got message: 3
2019-08-29 18:55:59.389646+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: pong with data: []
2019-08-29 18:56:26.528563+0530 Runner[5390:1152200] LOG SocketEngine: Writing ws: has data: false
2019-08-29 18:56:26.528636+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: ping with data: []
2019-08-29 18:56:26.528837+0530 Runner[5390:1152200] LOG SocketEngineWebSocket: Sending ws: as type: 2
2019-08-29 18:56:26.833262+0530 Runner[5390:1152406] LOG SocketEngine: Got message: 3
2019-08-29 18:56:26.833730+0530 Runner[5390:1151713] LOG SocketIOClient{/}: Handling event: pong with data: []
@ManojMM026 if you are looking for ack, please use as in example https://github.com/infitio/flutter_socket_io/blob/e31e07db012840af392e6b71cd0085d74b1015ec/example/lib/main.dart#L102
No, I am not looking for ack. But why does it work on android as expected? it goes into my parse function for android and not for ios?
@ManojMM026 can you try the example setup and see if it works fine?
@tiholic I added try catch and tried to debug issue. I have a error
'_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
but this works for Android not for ios
'_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
@ManojMM026 is that coming from _handleData in socket.dart?
I have Response parsing class something like this
class IdentifyResponse {
Data data;
int exit;
String topic;
int v;
IdentifyResponse({this.data, this.exit, this.topic, this.v});
factory IdentifyResponse.fromJson(Map<String, dynamic> json) {
return IdentifyResponse(
data: json['data'] != null ? Data.fromJson(json['data']) : null,
exit: json['exit'],
topic: json['topic'],
v: json['v'],
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['exit'] = this.exit;
data['topic'] = this.topic;
data['v'] = this.v;
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
class Data {
String device_hash;
bool online;
String salt;
Data({this.device_hash, this.online, this.salt});
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
device_hash: json['device_hash'],
online: json['online'],
salt: json['salt'],
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['device_hash'] = this.device_hash;
data['online'] = this.online;
data['salt'] = this.salt;
return data;
}
}
It breakes in ios at
IdentifyResponse identifyResponse = IdentifyResponse.fromJson(data);
Android version works well, only ios gives me this error.
I have Response parsing class something like this
class IdentifyResponse { Data data; int exit; String topic; int v; IdentifyResponse({this.data, this.exit, this.topic, this.v}); factory IdentifyResponse.fromJson(Map<String, dynamic> json) { return IdentifyResponse( data: json['data'] != null ? Data.fromJson(json['data']) : null, exit: json['exit'], topic: json['topic'], v: json['v'], ); } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['exit'] = this.exit; data['topic'] = this.topic; data['v'] = this.v; if (this.data != null) { data['data'] = this.data.toJson(); } return data; } } class Data { String device_hash; bool online; String salt; Data({this.device_hash, this.online, this.salt}); factory Data.fromJson(Map<String, dynamic> json) { return Data( device_hash: json['device_hash'], online: json['online'], salt: json['salt'], ); } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['device_hash'] = this.device_hash; data['online'] = this.online; data['salt'] = this.salt; return data; } }It breakes in ios at
IdentifyResponse identifyResponse = IdentifyResponse.fromJson(data);Android version works well, only ios gives me this error.
@tiholic
I have a demo scheduled next week @tiholic it will be great if you can fix this quickly.
@ManojMM026 drop a mail to [email protected]
Issue logged here is descriptive enough, if not can you please tell me what more you need so that I can draft & send an email to you?
@ManojMM026 just drop a blank email, we can connect over a meeting and fix it.
I'm getting the same error. What's the solution? Thanks in advance. @ManojMM026 @tiholic
@bilalbaz1 please share socket.io plugin version, socket.io server version, and flutter version you're using.
@tiholic
**flutter**
adhara_socket_io: ^1.0.1+1
flutter_socket_io: ^0.6.0
**nodejs**
"socket.io": "^2.0.0",
It also works flawlessly on Android. It gives an error on ios.
SocketOptions _options = SocketOptions(
_socketRepository.url,
enableLogging: true,
transports: [Transports.webSocket],
query: {"kullaniciOdaId": widget.kullaniciOdalariModel.id},
namespace: "/",
);
_manager = SocketIOManager();
_socket = await _manager.createInstance(_options);
await _socket.connect();
He's sending a message. A message is sent to the other person over the socket. But on ios device, there is a problem connecting and listening.
Debug console https://gist.github.com/42ba634a5b8e873694041306758ff709.git