0

I'm using Pusher for real chat application.

I've created a web app and a mobile app using Ionic 4.

The app use private channels, and everything works well on web enviroment. During development i've tested the Ionic app on browser (ionic serve) and the chat works very well.

When I tried to test the app on a real IOS Device (also XCode emulator), i get an error in channel subscribtion

Unable to retrieve auth string from auth endpoint - received status 0 from https://...

I've tested the endpoint and works fine, even if I try to simulate the connection from the device as a simple API.

So I cannot understand where is the problem. If I use a default channel (so no private) everything works fine also on IOS Device.

I'm thinking the problem should be on some Cordova/Ionic configuration?

Here's the code I use for Pusher setup and subscription (works if run on the browser with ionic)

this.pusher = new Pusher(this.environment.pusherKey, {
        cluster: 'eu',
        encrypted: true,
        authEndpoint: this.mainService.hostEndpoint + 'user/pusherAuth',
    });

this.pusher.subscribe(channelName)

Who's the hero who can help me solve this problem? :) I don't want to rollback on the not a private channel just as a workaround for the problem.

Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
Francesco
  • 189
  • 1
  • 1
  • 10
  • What is the response from your auth endpoint when you have simulated a device? – doydoy Jan 27 '20 at 15:13
  • When I try with browser, i get the right response. When I try with real device, i get no response from the device log, so the error "Unable to retrieve auth string from auth endpoint - received status 0 from https://..", even if the server log create the right response – Francesco Jan 28 '20 at 09:02
  • If the code is the same for both device and browser then it could be a networking issue - error code 0 could be that the request timed out and so no HTTP code was set by the server. Do you see incoming requests to your auth endpoint when you run the code in your device? – doydoy Jan 28 '20 at 10:14
  • Yes, that's strange because the server log receive the request and set the response properly. If I try to call the same endpoint from the app without pusher, i get the right response – Francesco Jan 28 '20 at 14:34
  • Could you share the full error? Is the URL in the error message actually your server or is it coming from Pusher? Are you using HTTPS when accessing the auth endpoint in the browser or HTTP? – doydoy Jan 28 '20 at 16:33
  • I use HTTPS and the error comes from Pusher response on subscription_error event. The full error is Unable to retrieve auth string from auth endpoint - received status 0 from ... with my endpoint URL Even if i try using HTTP i received the same error (always on device, not on the browser) – Francesco Jan 29 '20 at 06:54
  • The error truly does appear to be an issue between your device/app and your auth endpoint and not an issue with your implementation of channels. I would advice that you focus investigation on that area – doydoy Jan 29 '20 at 11:45

1 Answers1

1

for me i had the same issue and fixed that with adding 'Access-Control-Allow-Origin' header to my server response.

A Harfoush
  • 11
  • 1