IoT Example #41

Closed
opened 2020-04-19 02:30:34 +00:00 by Ghost · 5 comments

Hey AJ,

I watched some of your talks on greenlock express and really appreciate how you approach this problem. Great job!

I looked for some examples on IoT, but didn't find any, and maybe you can point me in the right direction. If I may explain my use case:

I have a device that runs node + express + socket.io. I'm able to communicate with the device and successfully get data by hitting its IP address using http via local network. Now, when I communicate with the device via a website that has https, I get Mixed Content Blocking, of course.

How can I use greenlock to serve the express + socket.io app on the device with https?

Thank you in advanced,

Alex

Hey AJ, I watched some of your talks on greenlock express and really appreciate how you approach this problem. Great job! I looked for some examples on IoT, but didn't find any, and maybe you can point me in the right direction. If I may explain my use case: I have a device that runs node + express + socket.io. I'm able to communicate with the device and successfully get data by hitting its IP address using http via local network. Now, when I communicate with the device via a website that has https, I get Mixed Content Blocking, of course. How can I use greenlock to serve the express + socket.io app on the device with https? Thank you in advanced, Alex
Owner

Hi Alex,

I think you may be describing two issues:

  1. running the webserver on a different port than the websocket
  2. optimizing local http for internal vs https for external

First, I'd recommend ws over socket.io because you probably don't need support for msie6 and ws is a lot simpler.

That said, both have methods to use the main webserver rather than running on separate ports. See:

Second, if you need to optimize for internal-only network calls, you can either use local DNS to issue different IP addresses than the public DNS, or you can use a domain that resolves to the local address - device.example.com vs local.device.example.com.

Let me know if that helped.

If so, tips appreciated: https://www.buymeacoffee.com/coolaj86

Hi Alex, I think you may be describing two issues: 1. running the webserver on a different port than the websocket 2. optimizing local http for internal vs https for external First, I'd recommend `ws` over `socket.io` because you probably don't need support for `msie6` and `ws` is a lot simpler. That said, both have methods to use the main webserver rather than running on separate ports. See: - https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/websockets/server.js - https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/socket.io/server.js Second, if you need to optimize for internal-only network calls, you can either use local DNS to issue different IP addresses than the public DNS, or you can use a domain that resolves to the local address - device.example.com vs local.device.example.com. Let me know if that helped. If so, tips appreciated: https://www.buymeacoffee.com/coolaj86
Author

Thank you for your response, AJ!

I've taken your advice and went with plain ws. Also, I don't need express anymore (or use a different port) so I'm just using ws with the main webserver. Issue 1 solved.

For issue 2, how can I do either of those things? Do you have any examples or tutorials you can point me to?

Very helpful, coffee bought!

Thank you for your response, AJ! I've taken your advice and went with plain `ws`. Also, I don't need express anymore (or use a different port) so I'm just using `ws` with the main webserver. Issue 1 solved. For issue 2, how can I do either of those things? Do you have any examples or tutorials you can point me to? Very helpful, coffee bought!
Owner

Thanks.

As for the issue of local vs public DNS, that's very, very much outside the scope of Greenlock and very app / site specific.

A properly configured network will do "hairpinning" automatically for internal devices - meaning that the router will translate the external public address to the internal NAT address automatically without actually round-tripping outside - so you should be able to always use the external public address and never use the IP address and it should work just fine.

However, in practice it just really depends on how your network is set up and how much smarts you want to put into your app.

Thanks. As for the issue of local vs public DNS, that's very, very much outside the scope of Greenlock and very app / site specific. A properly configured network will do "hairpinning" automatically for internal devices - meaning that the router will translate the external public address to the internal NAT address automatically without actually round-tripping outside - so you should be able to _always_ use the external public address and never use the IP address and it _should_ work just fine. However, in practice it just really depends on how your network is set up and how much smarts you want to put into your app.
Owner

And if I misunderstood what you're trying to do, then that advice may be completely invalid...

And if I misunderstood what you're trying to do, then that advice may be completely invalid...
Owner

Closing this out because we've talked IRL.

Closing this out because we've talked IRL.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: root/greenlock-express.js#41
No description provided.