During development, I tunnelled all the my product/created and product/updated post requests through ngrok to my localhost and everything was working fine, but once in awhile I noticed it might miss a hook and not receive it, but this problem happens almost all the time in production for me on both my stores.
The moment I switched everything to production, I deleted the old hooks, re registered them using the live domain, and when I request a list of registered web hooks, I can see that they are active from the "is_active" flags. But for some weird reason, when I go through the same workflow as I did during development, I don't see any of the post requests being received by my server at all, but once in awhile, I might see 1 get received and my server will do its thing with that hook.
I thought it might have had something to do with my SSL/TLS setup, so I went to https://www.ssllabs.com/ to do a quick test. Everything was graded A, the only thing that I noticed was that my certificate #2 or my CA bundle was not trusted for whatever the reason. So I actually removed the CA cert from my server and only used my RSA/Cert instead for the credentials. However, in another PHP app that we made for BigCommerce, it is using the same type of certificate generated as the one that I'm using right now through LetsEncrypt, and in that PHP app all the hooks are received properly.
Given all this, I still can't seem to quite pinpoint where the problem lies. When I tunnelled everything through NGROK, I registered the hooks to the https url given to me, https://xxxx.ngrok.io -> localhost. Then on my node server, I created a server using http instead of https to avoid 502 bad gateway conflicts. So the only differences is me switching from using ngrok to my own https using https.createserver.
Any ideas on what the problem might be?
https
.createServer(
{
key: app.get('RSA_KEY'),
cert: app.get('SSL_CRT'),
ca: app.get('SSL_CA')
},
app
)
.listen(HTTPS_PORT, async function() {
... some code
})
app is express.router()
Related
I have a bit of a problem with a web page I'm making. Here's the situation :
I have a working NodeJs server that's online, hosted on a VPS.
I'm making a webpage that makes requests to this server. The requests work when I'm testing them from localhost or my local network.
When I put my website on my hosting service (different from the server), the requests fail.
Google Chrome return this error :
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
The domain I have registered for my webpage has TSL1.3 I think, it it https for sure. So I thought it was a mismatch, like my website couldn't make requests to a simple http server that doesn't have any SSL or whatnot.
But when I looked into setting my server to use SSL or TSL or something like that, I got really confused. People recommended I use cloudflare as it provides certificates for free, but Cloudflare only works with domains, not stuff that runs on VPS with only an IP adress. I also tried following Certbot instructions to make a certificate myself but my VPS doesn't support snapd, even though it's Ubuntu 20.04.
Any attempt on my part to follow the rabbit hole of SSL certificates hasn't yielded anything, that's why I'm posting here. I don't even know if somehow getting a ssl certifcate will solve the problem.
Any help is much appreciated
I have created a simple GraphQL Subscription using Nest.js/Apollo GraphQL over Node.js. My client application which is a react.js/apollo client works find with the server. The client subscibes to the server via GraphQL similar to:
subscription
{
studentAdded
{
id
}
}
My problem is that it works only locally. When I deploy my server back-end to a hosted docker over internet, client won't receive data anymore.
I have traced the client, it sends GET request on ws://api.example.com:8010/graphql and receives the successful HTTP/1.1 101 Switching Protocols response. However, nothing is received from server like when the server was on my local machine. Checking the remote server log showed me that the client successfully connects to server. There, I can see onConnect log messages.
Now I need any guidance to solve the problem.
I check several things myself. Firstly, I thought WebSocket address is prohibited in the network but then realized that it is on same port as normal HTTP. Secondly, supposed that WebSocket messages/frames are transmitted over UDP but I was not correct, it is over TCP and no need to worry about network settings.
Additionally I have read several github threads and StackOverflow questions. But did not find any clue. I am not directly using Node.js/WebSocket, instead, I am using Nest.js/GraphqQL subscription. It has made my search tougher.
Your help is highly appreciated.
I use a service called glitch.me to host my Node.js project, and they only allow you to open one port internally. At the moment, my Node.js server can only handle HTTP requests, but glitch.me proxies my traffic for me, effectively allowing the client to communicate indirectly using HTTPS. My project heavily relies on the use of WebSockets, and they work perfectly when accessing it directly via example.glitch.me (the url provided by glitch.me). However, I need to connect this project to my custom domain (example.xyz), all traffic of which is proxied through Cloudflare. However, when attempting to establish a WebSocket connection through my custom domain (in other words: via Cloudflare), the socket connection is never established.
Now, I realise that this sounds very specific, but I think it's possible to generalise here:
WebSockets work:
client => glitch.me => my backend
client => A => my backend
Webockets don't work:
client => cloudflare => glitch.me => my backend
client => A => B => my backend
Note: HTTP/HTTPS still works for both domains.
I added logging on the server-side every time a WebSocket connection was established, and sure enough the server receives the connections! However, the client is never notified and in Chrome Developer tools it shows that the request never completed. Remember, everything is working perfectly when the traffic is not routed through Cloudflare.
I have full understanding for the fact that it may be impossible for you to resolve my issue with the information given to you, but I'm not asking you to do so. My question is simply this: where does the problem lie? Does the response from my backend get stuck somewhere along the way and doesn't reach all the way through? I have contacted both glitch.me and Cloudflare and they have both confirmed that they fully support WebSocket traffic.
What is the most probable cause of my problem? From there I could probably fix it!
Edit: I uses the ws package on npm on the backend and standard JavaScript WebSockets on the frontend.
Note: this has nothing to do with NPM (which is what comes up the most when googling this error):
I have a Node server which is trying to make https calls to a IIS/.Net server. My understanding is that when my Node server is playing the part of the "client" I don't need to attach any certificates to the options (var Request = Https.request(Options, function(Response) { ... }); ), however, recently when the IIS/.Net server updated its certificates, Node started throwing CERT_UNTRUSTED errors.
The obvious culprit is the IIS.Net server and/or its certificates, however, that server can be successfully reached by non-Node servers (or fiddler, for example).
The other oddity is that all this code was working fine till the certificates on the IIs.Net server expired and were reset.
Thanks in advance!
I got this to work using the answer found at a similar post:
Unable to verify leaf signature
Still not sure why renewing the certificates caused this to happen, but either way, the ssl-root-cas/latest module did the trick.
I can create an http server and it works fine, but as soon as I try to use https instead, the server runs without errors but I cannot connect to it at all.
HTTP (working):
http.createServer(app).listen(process.env.PORT, process.env.IP);
HTTPS (not working):
var options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
};
https.createServer(options, app).listen(process.env.PORT, process.env.IP);
There are no errors in either method, but when I use HTTPS, there is no response when visiting the webpage and the server acts like it's not even receiving a request. Is there something wrong with the port I'm using from the Cloud9 environment? I have tried for hours to figure out what the problem is but haven't made any progress, hopefully someone can help out.
I'm afraid HTTPS will currently not work on Cloud9, as this requires the usage of other ports that are currently not opened for security reasons. We're working on a solution for this, but this will not be available on the short term yet.
For now, I recommend using two sets of configuration for development and production environments: the development environment can then just use HTTP, and production environments can use HTTPS.
Please keep an eye on our Twitter feed and blog for updates on this!