twilio / twilio-chat-demo-android

Chat API Demo Application for Android
MIT License
63 stars 51 forks source link

Unable to establish connection to Twilio Sync service #125

Closed ch-edison closed 3 years ago

ch-edison commented 4 years ago

Before filing an issue please check that the issue is not already addressed by the following:

Remove the above lines from the template! Fill in ALL fields in the following:

Description

When I run the android application I get the following error E/TwilioChat: Error creating Twilio Chat Client: Unable to establish connection to Twilio Sync service

Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTSzM4NWJiYmQ0YzUwNDRkNTRiNTRkYmEwMTQ4OWY3MDJiLTE1ODE1MjcwNjciLCJncmFudHMiOnsiaWRlbnRpdHkiOiJHb2xkZW5Zb2xhbmRhRXNzZXgiLCJ2aWRlbyI6e30sImNoYXQiOnsic2VydmljZV9zaWQiOiJJU2YxNDRkNmQ2Mzc4ZjRkMDQ4NTAxMGQxZDlmMTNiOGE0In0sImRhdGFfc3luYyI6eyJzZXJ2aWNlX3NpZCI6ImRlZmF1bHQifX0sImlhdCI6MTU4MTUyNzA2NywiZXhwIjoxNTgxNTMwNjY3LCJpc3MiOiJTSzM4NWJiYmQ0YzUwNDRkNTRiNTRkYmEwMTQ4OWY3MDJiIiwic3ViIjoiQUMxYzU3ZWIwM2YyN2E5MjA1NDljYWRiOWExZWNkMDA4NSJ9.OwgrfK_HKArdoA57pTPvj4T91KitDKWZsZVviDW87eA

Expected Behavior should log in

Actual Behavior throws an error " Error creating Twilio Chat Client: Unable to establish connection to Twilio Sync service"

Reproduces how Often every time

Logs Versions All relevant version information for issue. dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' implementation 'com.twilio:chat-android:4.0.0' implementation 'com.koushikdutta.ion:ion:2.1.7' implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation "com.twilio:sync-android:0.8.7" }

Android API 28

Android Device Redmi note 8

berkus commented 4 years ago

Please try with the latest released SDK version.

ch-edison commented 4 years ago

Please try with the latest released SDK version.

I have already tried it with version 4.2.9, but it still does not work

berkus commented 4 years ago

So what is in the logs?

There's a manual on how to collect proper debug logs here.

berkus commented 4 years ago

Also, try removing empty video grant from the token:

"grants": {
    "identity": "GoldenYolandaEssex",
    "video": {},   <--- remove this
    "chat": {
      "service_sid": "ISf144d6d6378f4d0485010d1d9f13b8a4"
    },
    "data_sync": {
      "service_sid": "default"
    }
  },
AnwarSamir commented 4 years ago

I have already tried it with version 4.2.9, but it still does not work till now but trying to use vpn it work fine with me

ch-edison commented 4 years ago

This is the log file, and remove that line "video": {}, <--- remove this and the same error still appears

logs.txt

ch-edison commented 4 years ago

@berkus

Also, try removing empty video grant from the token:

"grants": {
    "identity": "GoldenYolandaEssex",
    "video": {},   <--- remove this
    "chat": {
      "service_sid": "ISf144d6d6378f4d0485010d1d9f13b8a4"
    },
    "data_sync": {
      "service_sid": "default"
    }
  },

This is the log file, and remove that line "video": {}, <--- remove this and the same error still appears

logs.txt

ch-edison commented 4 years ago

I have already tried it with version 4.2.9, but it still does not work till now but trying to use vpn it work fine with me

How do I use the vpn, can you explain a little more please?, thank you

berkus commented 4 years ago

@ch-edison either your internet is down or DNS does not work, it cannot resolve host to connect to:

Twilsock Websocket | reportConnectFail Could not resolve host tsock.us1.twilio.com: Host not found (authoritative), 12

berkus commented 4 years ago

Try resolving that host manually using nslookup or dig and see if you can.

ch-edison commented 4 years ago

Try resolving that host manually using nslookup or dig and see if you can.

@berkus sale lo siguiente con dig

dig tsock.us1.twilio.com

; <<>> DiG 9.14.10 <<>> tsock.us1.twilio.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29203
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;tsock.us1.twilio.com.          IN      A

;; ANSWER SECTION:
tsock.us1.twilio.com.   1705    IN      CNAME   tsock.us1.r.twilio.com.
tsock.us1.r.twilio.com. 135     IN      CNAME   rtd-twilsock-239837944.us-east-1
.elb.amazonaws.com.
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 52.73.45.207
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 35.153.58.70
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 35.153.85.184
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 35.171.234.243
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 54.165.184.200
rtd-twilsock-239837944.us-east-1.elb.amazonaws.com. 46 IN A 34.228.50.198

;; Query time: 130 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Feb 13 09:21:14 Hora est. PacÝfico, SudamÚrica 2020
;; MSG SIZE  rcvd: 232
berkus commented 4 years ago

@ch-edison

Did you run that on the device?

AnwarSamir commented 4 years ago

I have already tried it with version 4.2.9, but it still does not work till now but trying to use vpn it work fine with me

How do I use the vpn, can you explain a little more please?, thank you

try to download Thunder VPN app it will work with you but this not a professional solution Twillio must solve this fatal Bug

berkus commented 4 years ago

@AnwarSamir if it works through VPN but doesn't work without, it means there's a problem with DNS resolution in your local network.

Unfortunately, we are not able to do anything about your local network conditions.

AnwarSamir commented 4 years ago

There are a lot of developers i have worked with on the same project and in different areas and the same issue happen with them @berkus

berkus commented 4 years ago

Sorry to hear that @AnwarSamir but in this particular case we can see from the logs its the DNS resolution problem but it could be different issues for your other fellow developers - we’d need to see their logs to make sure.

abdelmagied94 commented 4 years ago

@berkus I have the same issue. The app works fine in the android emulator when I tried to run in the device, this issue happens. When I set trace for log level, I receive this: Twilsock D: Emitting connectionError({"terminal":false,"message":"Unable to resolve host \"tsock.us1.twilio.com\": No address associated with hostname","httpStatusCode":null,"errorCode":null}) I wonder why it works with the emulator and not with the device and both use the same network. When I enabled the VPN on the device, it works fine.

berkus commented 4 years ago

Probably a difference in dns provider between emulator (running on computer) and on device. When you enable vpn the dns provider probably changes.

You can check by adb shelling into the phone and using nslookup or dig to see which dns servers are queried with vpn off and on and compare. You will also see why that address is not resolved.

ArcherN9 commented 4 years ago

I received the same error today for the Singapore server. As recommended by @berkus, I did a dnslookup, but with cloudfare & Google DNS. Server SG1 returns NXDOMAIN. Swithced to us1 and it works as expected. Something up with Singapore server?

➜  ~ dig tsock.sg1.twilio.com @1.1.1.1

; <<>> DiG 9.10.6 <<>> tsock.sg1.twilio.com @1.1.1.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 43254
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;tsock.sg1.twilio.com.      IN  A

;; AUTHORITY SECTION:
sg1.twilio.com.     300 IN  SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300

;; Query time: 464 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Wed May 06 14:09:46 IST 2020
;; MSG SIZE  rcvd: 139
rusmonster commented 4 years ago

@ArcherN9 sg1 does not exist at the moment, please use us1 If you really need it in Singapore or any other region - please contact twilio support