Hi,
I am using a local virtual Bitnami Parse Server. Everything works normally. I can connect to ParseServer with HTTPS. I can connect to LiveQuery via ws:// but not via wss://.
How can I configure LiveQuery Server with WSS?
ParseServer version: 4.9.3
/opt/bitnami/parse/config.json like this:
{
âappIdâ: âxxxâ,
âmasterKeyâ: âxxxxâ,
âappNameâ: âparse-serverâ,
âmountPathâ: â/parseâ,
âportâ: â1337â,
âhostâ: â0.0.0.0â,
âserverURLâ: âhttps://xxx/parse â,
âpublicServerURLâ: âhttps://xxxx/parse â,
âdatabaseURIâ: âmongodb://bn_parse:[email protected] :27017/bitnami_parseâ,
âliveQueryâ: {
âclassNamesâ: [âclass1â,âclass2â]
},
âstartLiveQueryServerâ: âtrueâ,
âliveQueryServerOptionsâ: {
âappIdâ: âxxxxâ,
âserverURLâ: âwss://xxxx:1337â,
âmasterKeyâ: âxxxxâ,
âlogLevelâ: âVERBOSEâ
}
}
Would you mind to share the code that you are using to connect from client and also the error message that you have?
Client error message:
âŚ
flutter: â-- Parse Request
flutter: curl -X GET -H âuser-agent: Flutter Parse SDK 2.1.0â -H âŚ
âŚ
flutter: LiveQuery: : Error: HandshakeException: Handshake error in client (OS Error:
WRONG_VERSION_NUMBER(tls_record.cc:242))
flutter: â-- Parse Response
Class: LiveQuery
Function: ParseApiRQ.liveQuery
Status Code: -1
Type: UnknownError
Exception: HandshakeException: Handshake error in client (OS Error:
WRONG_VERSION_NUMBER(tls_record.cc:242))
â°â
flutter: LiveQueryReconnectingController: Retrytimer set to 500ms
flutter: LiveQueryReconnectingController: LiveQueryClientEvent.DISCONNECTED
Client:
parse_server_sdk_flutter: ^2.1.0
Like this Widget:
ParseLiveListWidget<ParseObject>(
query: query,
lazyLoading: true,
preloadedColumns: ["test1", "sender.username"],
childBuilder:
(BuildContext context, ParseLiveListElementSnapshot<ParseObject> snapshot) {
if (snapshot.failed) {
return const Text('something went wrong!');
} else if (snapshot.hasData) {
return ListTile(
title: Text(
snapshot.loadedData.get<String>("text"),
),
);
} else {
return ListTile(
title: Text(
"loading comment from: ${snapshot.preLoadedData?.get<ParseObject>("sender")?.get<String>("username")}",
),
);
}
},
);
I guess, this is livequery server certificate issue. How can I bind the certificate to livequeryserver?
Could you share the code that you are using to initlize Parse/Live Query sdk?
ParseServer SDK initialize:
// Initialize parse
await Parse().initialize(
APPKEY,
APIURL,
masterKey: ââ,
clientKey: ââ,
liveQueryUrl:âwss://fqdn:1337â,
debug: true,
autoSendSessionId: true,
appName: kIsWeb ? âXâ : null,
appVersion: kIsWeb ? âVersion 1.0â : null,
appPackageName: kIsWeb ? âfqdnâ : null
);
What is the address that you are using to perform the https request to the rest api?
the address:
https://api02.westeurope.cloudapp.azure.com/parse
wss://api02.westeurope.cloudapp.azure.com:1337
They should be in the same port. Have you tried live query with wss://api02.westeurope.cloudapp.azure.com
?
I changed to wss://api02.westeurope.cloudapp.azure.com
same as client side and server side: wss://api02.westeurope.cloudapp.azure.com
âliveQueryâ:{
âclassQueryâ: [âClass1â,âClass2â]
},
âstartLiveQueryServerâ: âtrueâ,
âliveQueryServerOptionsâ:{
âappIdâ: âxxxxâ,
âserverURLâ: âwss://api02.westeurope.cloudapp.azure.comâ,
âmasterKeyâ: âxxxâ
}
Error message changed:
flutter: LiveQueryReconnectingController: Retrytimer set to 500ms
flutter: LiveQueryReconnectingController: LiveQueryClientEvent.DISCONNECTED
flutter: LiveQuery: : Error: WebSocketException: Connection to âhttps://api02.westeurope.cloudapp.azure.com:0 #â was not upgraded to websocket
flutter: â-- Parse Response
Class: LiveQuery
Function: ParseApiRQ.liveQuery
Status Code: -1
Type: UnknownError
Exception: WebSocketException: Connection to âhttps://api02.westeurope.cloudapp.azure.com:0 #â was not upgraded to websocket
yp19
May 7, 2021, 5:45am
11
I am also having the same issue, @ParseServerCandir did you able to resolve it? If so, could you post it here. Thanks in advance
No, not yet. I think we will solve the problem with @davimacedo âs support, or maybe others.
Could you please share the code that you are using to mount parse api and live query on express.js?
yp19
May 7, 2021, 8:34pm
14
Server:
const ParseServer = require('parse-server').ParseServer;
const RedisCacheAdapter = require('parse-server').RedisCacheAdapter
const http = require('http');
const firebaseAuthAdapter = require('parse-server-firebase-auth-adapter');
const databaseUri = process.env.DATABASE_URI;
const cloudCodeMain = process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js';
const appId = process.env.APP_ID;
const masterKey = process.env.MASTER_KEY;
const serverURL = process.env.SERVER_URL || 'http://localhost:1337/parse'
const cacheRedisURL = process.env.CACHE_REDIS_URL;
const liveQueryRedisURL = process.env.LIVE_QUERY_REDIS_URL;
const port = process.env.PORT || 1337;
const mountPath = process.env.MOUNT_PATH || '/parse';
const mode = process.env.SERVER_MODE || '';
const gcsProjectId = process.env.GCS_PROJECTID || '';
const gcsBucket = process.env.GCS_BUCKET || '';
const config = {
databaseURI: databaseUri,
cloud: cloudCodeMain,
appId: appId,
masterKey: masterKey,
serverURL: serverURL,
cacheAdapter: new RedisCacheAdapter({
url: cacheRedisURL,
}),
liveQuery: {
classNames: ['MyClass'],
redisURL: liveQueryRedisURL,
},
filesAdapter : {
module: "@parse/gcs-files-adapter",
options: {
projectId: gcsProjectId,
bucket: gcsBucket
}
},
auth: {
firebase: firebaseAuthAdapter
}
}
console.log(JSON.stringify(config));
let enableLiveQuery = false;
if (mode === 'liveQuery') {
enableLiveQuery = true;
}
const app = express();
const api = new ParseServer(config);
app.use(mountPath, api);
const httpServer = http.createServer(app);
httpServer.listen(port,()=>{
console.log('server running on port ' + port);
});
if (enableLiveQuery) {
console.log('livequery server is running..');
ParseServer.createLiveQueryServer(httpServer, {
appId: appId,
masterKey: masterKey,
serverURL: serverURL,
redisURL: liveQueryRedisURL,
});
}
module.exports = {
app,
config,
};
Flutter Parse:
await Parse().initialize(
keyParseApplicationId,
keyParseServerUrl,
debug: true,
liveQueryUrl: keyLiveQueryUrl,
coreStore: await CoreStoreSharedPrefsImp.getInstance(),
autoSendSessionId: true,
);
@yp19 what is the value of âkeyLiveQueryUrlâ?
liveQueryUrl: keyLiveQueryUrl
like mine?
yp19
May 7, 2021, 9:23pm
16
yp19
May 7, 2021, 9:26pm
17
flutter log:
I/flutter ( 8004): LiveQuery: : Socket opened
I/flutter ( 8004): LiveQuery: : ConnectMessage: {op: connect, applicationId: appid, sessionToken: r:token}
I/flutter ( 8004): LiveQuery: : Done
I/flutter ( 8004): LiveQueryReconnectingController: Retrytimer set to 10000ms
I/flutter ( 8004): LiveQueryReconnectingController: LiveQueryClientEvent.DISCONNECTED
@yp19 well, what is the value of âredisURL: liveQueryRedisURLâ?
and âserverURL: serverURLâ?
yp19
May 7, 2021, 10:30pm
19
redisURL: hostRedisServerURL
serverURL: https://objstore.domain.com
yp19
May 7, 2021, 10:35pm
20
By the way, the above setup is working properly with Javascript. I have a Javascript test client, it is receiving the new objects created with LiveQueries