shamblett / mqtt_client

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

Trying to connect to an appsync subscription... #92

Closed bobwiller closed 5 years ago

bobwiller commented 5 years ago

Trying to spike some code to connect to an AppSync Subscription websocket at "wss://a307xxxxxxxxx0-ats.iot.us-east-1.amazonaws.com/mqtt" but it seems no matter what i have tried i get a WebSocketException that Conection to '' was not upgraded to websocket.

I am assuming this is because the Connection and Upgrade headers need to be set, but not sure how to do this? Has anyone else been successful connecting to an AppSync subscription in Dart or Flutter? Thanks, Bob

shamblett commented 5 years ago

We have lots of users using ws and wss, if you look through the closed issues you'll see a number of things were found and fixed for the websocket implementation. The websocket upgrading is not done by the client per se but by the Dart runtime however there are a couple of things you can try -

  1. Change the protocols string sent in the ws header using the websocketProtocols setter, see the API docs.
  2. Try setting useAlternateWebSocketImplementation, this was added by a user who was having probs with IIRC Amazon specifically.

I don't know what an AppSync Subscription is but if it conforms to standard websocket protocol it should work.

From your log extract above the 'connection to' string should print the URL, it seems not to.

marwfair commented 5 years ago

@bobwiller Were you able to make this work?

bobwiller commented 5 years ago

@marwfair gist here: https://gist.github.com/bobwiller/b669f3476fcd2805b4f25b96243d859a

marwfair commented 5 years ago

@bobwiller Thank you! That was just what I was needing.