eclipse / ponte

Ponte Project
Other
362 stars 61 forks source link

Possibility of bridging CoAP to another HTTP server #8

Closed p-diogo closed 10 years ago

p-diogo commented 10 years ago

Hello there!

I know Ponte, as is, does not allow for bridging between different server locations, but I was wondering If I could tweak it to suit my needs (hard code the bridge to another HTTP server). The HTTP server will be working in the same machine as Ponte, as it will be a deployment of a M2M GSCL using http://eclipse.org/om2m/. I was thinking of trying to tweak /lib/coap.js's handlePUT function by taking a look at the path: if it matches a PUT request to the GSCL (its special URI), then it should proxy to that specific HTTP server IP and port. I also thought of disabling the startup of Ponte's HTTP server entirely, but I can't do that since I'm making use of Mosca's built-in websocket... Although it is not the best solution, the first option might just work for my special case... I still don't know how to do it, as I'm a complete newbie to nodejs, but I'll figure it out...

@mcollina, Is there any other better option? Thanks in advance.

Regards, Pedro.

mcollina commented 10 years ago

What you can do is embed Ponte and add an 'updated' event handler to it and then make an HTTP call to om2m.

Plus, if you want to add an option flag to switch on/off the REST request handlers, please do so and send a contribution.

p-diogo commented 10 years ago

Yeah, thanks Matteo! Will go with the embedded way. However, still have a few questions:

If I disable HTTP's REST request handlers, will I still have connectivity via Mosca's websocket? If I do not disable it, I will still have oM2M on port 8181 and node's HTTP on 8080 (changed it from default 3000)...So, when the 'updated' event handler triggers, can I make an HTTP call to this specific 8181 port?

p-diogo commented 10 years ago

Just a quick update (had to pause this part of the project for a while): everything is working as expected, but I can not switch off the HTTP service in embedded mode. I'm using Ponte in two different applications on the same machine, so forcibly disabling it is not an option as I need that handler on the other application. I need to learn how to properly work with nodejs in the future!

Anyway, everything is fine now.

Thank you very much!