shamblett / mqtt_client

A server and browser based MQTT client for dart
Other
548 stars 176 forks source link

connet to ssl://edge-mqtt.facebook.com #271

Closed milady4r closed 3 years ago

milady4r commented 3 years ago

Can anyone help me connect to this socket?

this my parameters

address : ssl://edge-mqtt.facebook.com:443

username: {"u":"[FBAN\/InstagramForAndroid;FBAV\/161.0.0.37.121;FBBV\/567310203415052;FBDM\/{density=3.0,width=1080,height=1920};FBLC\/fa_IR;FBCR\/Irancell;FBMF\/samsung;FBBD\/samsung;FBPN\/com.instagram.android;FBDV\/SM-A700FD;FBSV\/4.4.4;FBLR\/0;FBBK\/1;FBCA\/armeabi-v7a:armeabi;]","a":"Instagram","cp":128,"mqtt_sid":4614944,"nwt":1,"nwst":0,"chat_on":false,"no_auto_fg":true,"d":"cbd40bb7-c297-49c5-a","ds":"","fg":false,"ecp":0,"pf":"1","ct":"cookie_auth","aid":"567067343352427","st":["\/fbns_msg","\/pp","\/fbns_exp_logging","\/pubsub","\/ig_message_sync","\/t_region_hint","\/ig_realtime_sub","\/ig_send_message_response","\/ig_sub_iris_response"],"app_specific_info":{"platform":"android","app_version":"50.1.0.43.119","capabilities":"3brTvx8=","User-Agent":"Instagram 121.0.0.29.119 Android (7.1.2\/25; 160dpi; 960x540; SM-N976N; samsung; samsung; d2que; en_US)","Accept-Language":"en-US","ig_mqtt_route":"django","auth_cache_enabled":"0","pubsub_msg_type_blacklist":"{\"direct\":\"typing_type\"}","everclear_subscriptions":"{\"inapp_notification_subscribe_default\":\"17899377895239777\",\"inapp_notification_subscribe_comment\":\"17899377895239777\",\"inapp_notification_subscribe_comment_mention_and_reply\":\"17899377895239777\",\"inapp_notification_subscribe_story_emoji_reaction\":\"17899377895239777\",\"video_call_participant_state_delivery\":\"17977239895057311\",\"presence_subscribe\":\"17846944882223835\"}"}}

password has sessionid account login instagram password: 'sessionid=2548556%djljjjfafhhhnannf,a,,ga'

thats my code to connecting :

`Future connect(String server, int port, String clientIdentifier, String username, String password, {bool isSsl = false}) async { final client = MqttServerClient(server, clientIdentifier); //final client = MqttClient(server, clientIdentifier);

client.port = port;

client.secure = true;
final currDir = '${path.current}${path.separator}crt${path.separator}';
final context = SecurityContext.defaultContext;

//context.setTrustedCertificates(currDir + path.join('pem', 'roots.pem'));
client.securityContext = context;
//client.setProtocolV311();
client.setProtocolV31();
client.logging(on: true);
await client.connect(username, password);

}`

but gets this errors :

I/flutter ( 9842): 6-2021-04-24 15:22:03.552702 -- SynchronousMqttServerConnectionHandler::internalConnect - secure selected I/flutter ( 9842): 6-2021-04-24 15:22:03.553304 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect I/flutter ( 9842): 6-2021-04-24 15:22:03.557223 -- MqttSecureConnection::connect - entered I/flutter ( 9842): 6-2021-04-24 15:22:04.067751 -- MqttSecureConnection::connect - securing socket I/flutter ( 9842): 6-2021-04-24 15:22:04.070253 -- MqttSecureConnection::connect - start listening I/flutter ( 9842): 6-2021-04-24 15:22:04.075241 -- MqttServerConnection::_startListening I/flutter ( 9842): 6-2021-04-24 15:22:04.081055 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete I/flutter ( 9842): 6-2021-04-24 15:22:04.082916 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message I/flutter ( 9842): 6-2021-04-24 15:22:04.083890 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect I/flutter ( 9842): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 1447 I/flutter ( 9842): Connect Variable Header: ProtocolName=MQIsdp, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 I/flutter ( 9842): MqttConnectPayload - client identifier is : Android-125432102 I/flutter ( 9842): 6-2021-04-24 15:22:04.094063 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter ( 9842): 6-2021-04-24 15:22:04.857880 -- MqttConnectionBase::_onDone - calling disconnected callback Application finished.

shamblett commented 3 years ago

You seem to have connected successfully -

I/flutter ( 9842): 6-2021-04-24 15:22:04.081055 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete

The broker is rejecting your connect message because of a protocol failure, there are many reasons for this, try using a pared down connection message rather than the default -

final connMess = MqttConnectMessage()
      .withClientIdentifier('Android-125432102')
      .startClean() // Non persistent session for testing
      .authenticateAs(username, password)
  client.connectionMessage = connMess;
await client.connect(username, password);

You must send what your broker expects, also you need to use the MQTT version your broker requires, you should consult your broker specs for this. At the end of the day only your broker knows why its rejecting the connection, you should check your brokers logs.

milady4r commented 3 years ago

Thanks for the reply The previous error remains

1-2021-04-25 21:45:53.198783 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none 1-2021-04-25 21:45:53.471280 -- MqttConnectionBase::_onDone - calling disconnected callback 1-2021-04-25 21:45:58.200454 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none 1-2021-04-25 21:45:58.201470 -- SynchronousMqttServerConnectionHandler::internalConnect failed Unhandled exception: mqtt-client::NoConnectionException: The maximum allowed connection attempts ({3}) were exceeded. The broker is not responding to the connection request message (Missing Connection Acknowledgement?

shamblett commented 3 years ago

OK the client is telling you this -

The broker is not responding to the connection request message (Missing Connection Acknowledgement?

The only way to find out exactly why is to examine your brokers logs.