[Problems and symptoms]
Through “ionic serve”, chrome of windows normally communicates with ws://, and there is no problem in operation.
However, when running on android through the ionic cordova run android command, a connection request is made to wss://.
I coded for ws:// communication in the mobile application, but it keeps requesting the server with wss://.
Therefore, the connection fails because the server has set the use of ws instead of wss.
Please advise what is needed to use ws:// on Android.
[reference]
I plan not to set up to use wss:// as a policy.
[Server Settings]
I am using laravel server for backend.
The websocket configuration of the Laravel server is configured for ws:// communication, not wss://.
The current server config is as follows,
broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => false,
'encrypted' => false,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http',
],
],
websockets.php
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => true,
'enable_statistics' => true,
],
],
‘ssl’ => [
‘local_cert’ => null,
‘local_pk’ => null,
‘passphrase’ => null,
‘verify_peer’ => false,
‘verify_peer_name’ => false,
],
When you connect to the address below, you can check that the operation and settings of the Laravel server are normal.
http://bookingtong.codns.com/laravel-websockets
[Ionic-based mobile application settings]
package.json
pusher-js 4.3.1
cordova 10
code in app page
const pusher = new Pusher(key, {
wsHost: ‘bookingtong.codns.com’,
wsPort: 6001;
wsPath: ‘’,
forceTLS: false,
cluster: ‘mt1’,
enabledTransports: [‘ws’],
} as any);