Can't connect to parse server api when setting serverurl to https

Keywords: Parse - AWS - Technical issue - Secure Connections (SSL/HTTPS)

bnsupport ID: 7092297b-cadf-c097-0d08-f740d94aff7d

bndiagnostic output:

? Apache: Found possible issues
https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors-apache/
https://docs.bitnami.com/bch/apps/moodle/troubleshooting/deny-connections-bots-apache/

bndiagnostic failure reason: The suggested guides are not related with my issue

Description:
I first tried pointing my domain using the load balancer and a cert setup through the certificate manager but that didn’t work so figured it must be something with how the load balancer handles the certificate and went to plan b.

Plan B:
I changed the domain to point directly at the public ip of the ec2 instance and then setup an SSL cert using the bitnami lets encrypt option.

I can get to the parse dashboard using https just fine as long as I have the serverUrl option set to http:// and NOT https://. As soon as I switch to https there it can no longer connect to the api and I get cors errors (No ‘Access-Control-Allow-Origin’ header is present on the requested resource.).

I’m assuming somewhere somehow I need to add Header set Access-Control-Allow-Origin “*”. I tried setting this in the apache/vhosts directory on both the parse-vhost and parse-https-vhost files and restarted apache but no luck. Tried throwing it into the httpd.conf file as well but no luck.

Do I need to somehow set this up in an express middleware somewhere? This doesn’t really look like any express build I’ve ever seen before so not sure where or how to even go about trying that.

Our app needs to be hipaa compliant so once we are ready to push to production obviously ssl all the way through is a must and especially need the wss:// working.

Ok, this is strange but it finally just up and started working on it’s own just fine under https set for the serverUrl.

My only problem left is that when setting a subscription using the JS SDK I get a console error:
“WebSocket connect to ‘wss://akashichealthrecords.com/parse’ failed”

Other than that I “think” everything else is working now.

I should mention that liveQuery looks like it’s running, this is what I get in the parse log:

[12456] parse-server running on https://akashichealthrecords.com/parse
info: Parse LiveQuery Server starts running

Here's my parse config:
{
  "appId": "myappID",
  "masterKey": "XXXXXXXXX",
  "appName": "parse-server",
  "mountPath": "/parse",
  "port": "1337",
  "host": "127.0.0.1",
  "serverURL": "https://akashichealthrecords.com/parse",
  "databaseURI": "mongodb://bn_parse:XXXXXXXX@127.0.0.1:27017/bitnami_parse",
  "cloud": "/opt/bitnami/cloud/main.js",
  "liveQuery": {
    "classNames": ["User","Role"]
  },
  "startLiveQueryServer": "true",
  "liveQueryServerOptions": {
    "appId": "myappID",
    "serverURL": "wss://akashichealthrecords.com",
    "masterKey": "XXXXXX",
    "logLevel": "VERBOSE"
  }
}

Hi @sfraise77

Thanks for using Bitnami Parse!

Ok, this is strange but it finally just up and started working on it’s own just fine under https set for the serverUrl.

I am glad to hear that you were able to resolve your initial problem.

My only problem left is that when setting a subscription using the JS SDK I get a console error:
“WebSocket connect to ‘wss://akashichealthrecords.com/parse’ failed”

I assume that is the output you obtain from the client-side, but it’d also be interesting checking if the server has logged any error trace. Try to perform another connection and take a look at your parse log. Do you happen to see any message there?

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

[13246] parse-server running on https://akashichealthrecords.com/parse
info: Parse LiveQuery Server starts running
Termination signal received. Shutting down.e[38;5;6mparse e[38;5;5m20:00:08.69 e[0me[38;5;2mINFO e[0m ==> ** Starting Parse **
Configuration loaded from /opt/bitnami/parse/config.json
allowClientClassCreation: true
appId: myappID
appName: parse-server
cacheMaxSize: 10000
cacheTTL: 5000
cloud: /opt/bitnami/cloud/main.js
customPages: {}
databaseURI: mongodb://bn_parse:6Ji17Zx7rRjR@127.0.0.1:27017/bitnami_parse
enableAnonymousUsers: true
expireInactiveSessions: true
graphQLPath: /graphql
host: 127.0.0.1
idempotencyOptions: {"ttl":300,"paths":[]}
liveQuery: {"classNames":["User","Role"]}
liveQueryServerOptions: {"appId":"myappID","serverURL":"wss://akashichealthrecords.com/parse","masterKey":"6Ji17Zx7rRjR","logLevel":"VERBOSE","server":{"_events":{"connection":[null,null]},"_eventsCount":5,"_connections":0,"_handle":{"reading":false},"_usingWorkers":false,"_workers":[],"_unref":false,"allowHalfOpen":true,"pauseOnConnect":false,"httpAllowHalfOpen":false,"timeout":120000,"keepAliveTimeout":5000,"maxHeadersCount":null,"headersTimeout":60000,"_connectionKey":"4:127.0.0.1:1337"}}
logsFolder: ./logs
masterKey: ***REDACTED***
masterKeyIps: []
maxUploadSize: 20mb
mountPath: /parse
objectIdSize: 10
playgroundPath: /playground
port: 1337
protectedFields: {"_User":{"*":["email"]}}
revokeSessionOnPasswordReset: true
schemaCacheTTL: 5000
serverURL: https://akashichealthrecords.com/parse
sessionLength: 31536000
startLiveQueryServer: true
allowCustomObjectId: false
collectionPrefix: 
directAccess: false
enableExpressErrorHandler: false
enableSingleSchemaCache: false
mountGraphQL: false
mountPlayground: false
preserveFileName: false
preventLoginWithUnverifiedEmail: false
scheduledPush: false
verifyUserEmails: false
jsonLogs: false
verbose: false
level: undefined

[13371] parse-server running on https://akashichealthrecords.com/parse
info: Parse LiveQuery Server starts running

Ahh, overlooked another console error at the very top, websocket connection failed kept hitting is probably why I didn’t see it before.

I’m getting “subscription.on is not a function”. I’m following a video tutorial series on YouTube and using the following JS SDK:
https://npmcdn.com/parse/dist/parse.min.js

Here’s my code:

let User = new Parse.Object.extend('User');
let q = new Parse.Query('User');
q.equalTo('username', 'sfraise77@gmail.com');
let subscription = q.subscribe();

subscription.on('open', function() {
    console.log('opened');
});
subscription.on('update', function(obj) {
    console.log('Object updated', obj.attributes);
});

Reduced code to the following:

    let User = new Parse.Object.extend('User');
    let q = new Parse.Query('User');
    q.equalTo('username', 'sfraise77@gmail.com');
    let subscription = q.subscribe();

Still get the WebSocket connection to ‘wss://akashichealthrecords.com/parse’ failed.

I tried let subscription = await q.subscribe() but get console error saying await can only be used with async functions.

Where am I going wrong here?

Reworked code to this:

    let User = new Parse.Object.extend('User');
    let q = new Parse.Query('User');
    q.equalTo('username', 'sfraise77@gmail.com');
    let subscription = q.subscribe();

    q.subscribe().then(subscription => {
        subscription.on('open', (data) => {
            console.log(data.get('username') + ' opened');
        });
        subscription.on('update', (data) => {
            console.log(data.get('username') + ' updated');
        });
    })

Still get WebSocket error but no other errors.

Ok, realized the User class actually needs to be set as _User and Role needs to be _Role.

Still get WebSocket error.

Added a TestObject class and removed both user and role from everything involved with live query and just set it on TestObject.

Ended up with this code:

    let TestObject = new Parse.Object.extend('TestObject');
    let q = new Parse.Query('TestObject');
    q.equalTo('foo', 'bar');
    let subscription = q.subscribe();
    console.log(subscription);

Still getting websocket error.

I feel like I need to tweak something in apache conf somewhere for this, could that be the case?

I am sorry, but I think this goes out of the scope of this forum, which is to provide assistance related to the Bitnami stacks themselves. This seems to be intrinsically related to Parse as an application, including programmatically connecting to the Live Query Server (which seems to be running). Hence, it would be better if you reach out to a specialized community for further feedback on this.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

I dont think its parse, I think it’s something with the server or Apache ssl configuration under this bitnami ami.

As far as parse goes it’s working and says livequery server is running. The server itself is blocking wss:// connection from outside.

Do you have any examples of wss working under this ami build?

Here’s a bit from my apache log showing the 403’s:

64.xxx.79.xxx - - [03/Aug/2021:17:15:18 +0000] "OPTIONS /parse/classes/TestObject HTTP/1.1" 200 2
64.xxx.79.xxx - - [03/Aug/2021:17:15:18 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:18 +0000] "POST /parse/classes/TestObject HTTP/1.1" 200 245
64.xxx.79.xxx - - [03/Aug/2021:17:15:18 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:20 +0000] "OPTIONS /parse/health HTTP/1.1" 200 2
64.xxx.79.xxx - - [03/Aug/2021:17:15:20 +0000] "POST /parse/health HTTP/1.1" 200 15
64.xxx.79.xxx - - [03/Aug/2021:17:15:20 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:24 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:34 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:43 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:15:57 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:16:13 +0000] "GET /parse HTTP/1.1" 403 24
64.xxx.79.xxx - - [03/Aug/2021:17:16:21 +0000] "GET /parse HTTP/1.1" 403 24

I thought maybe updating parse could be a long shot at getting this to work so I followed the docs at https://docs.bitnami.com/aws/apps/parse/administration/upgrade/.

Doesn’t work, says it can’t install parse-dashboard when parse-dashboard already exists.

I think I’m going to have to just scrap this AMI and start over from scratch with a fresh linux ec2 and install/configure everything myself. I’m already several days into beating my head against this thing and getting no closer to getting the websocket piece working than I was when I started.

Now I’m really confused, parse-server latest says 4.5.0 but the package.json file says it’s 4.9.3.

There is an upstream issue in the Parse forum related to this same case and the user reports he/she is using version 4.9.3 as well, that is why I believe this is not directly related to the Bitnami stack:

https://community.parseplatform.org/t/we-can-connect-to-livequeryserver-via-ws-but-not-via-wss-how-can-we-configure-it-using-via-wss/1612/25

As far as parse goes it’s working and says livequery server is running. The server itself is blocking wss:// connection from outside.

Can you verify that the connection can be established from within the instance? I think there is some upstream issue with the wss connection for that version, as per the link I shared above.

Now I’m really confused, parse-server latest says 4.5.0 but the package.json file says it’s 4.9.3.

Yes, we detected this issue some time ago. The Parse team published a release using version 4.9.3 and tagged it as latest stable by accident for some time. However, it seems that they were merely tags and not a real release (a bump in the version of the application). We created an upstream issue notifying the team, you can see it here:

https://community.parseplatform.org/t/version-4-9-3-seems-to-disappear-from-github/1839

I think I’m going to have to just scrap this AMI and start over from scratch with a fresh linux ec2 and install/configure everything myself. I’m already several days into beating my head against this thing and getting no closer to getting the websocket piece working than I was when I started.

I’m sorry to hear that. If this is something related to version 4.9.3 (or 4.5.0) I can provide you with a link to download a previous version of the Application in OVA format (a local virtual machine that you can run using VMware Fusion or VirtualBox) or a installer that you can run on a fresh linux ec2 machine (running version 4.1.0-0) so you can try.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Ahh, now that’s making a little more sense and why no matter what I’ve tried I can not get wss to connect to client. I even went through apache conf hell yesterday for a few hours and nothing worked.

Can I just install the previous version within this ami setup without messing everything up? For example, just wipe the node modules folder from the parse directory and then run something like

npm install parse-server@4.5.0 or npm install parse-server@4.4.0?

I assume the config.json would still remain and still work?

Go ahead and send me a link for the ami with the previous version of parse in it if there’s no way to downgrade this existing parse-server version easily.

Hi @sfraise77

Can I just install the previous version within this ami setup without messing everything up? For example, just wipe the node modules folder from the parse directory and then run something like

Maybe you can try to downgrade the version manually, but we don’t have any guides on the process and you’ll need to investigate this.

Go ahead and send me a link for the ami with the previous version of parse in it if there’s no way to downgrade this existing parse-server version easily.

Here you have the AWS AMI for an instance with Parse version 4.3.0: ami-081b43b4b2dd5c763.4

Alternatively, you can also install Parse using an old version (4.1.0) of a Bitnami Native Installer on a Linux EC2 instance (or even your local machine):

wget https://downloads.bitnami.com/files/bitnami-downloads/files/stacks/parse/4.1.0-0/bitnami-parse-4.1.0-0-linux-x64-installer.run
chmod +x bitnami-parse-4.1.0-0-linux-x64-installer.run
sudo ./bitnami-parse-4.1.0-0-linux-x64-installer.run

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Is there supposed to be a link there?