# Setting up Webhook connection between 2 servers

**URL:** <https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192>\
**Category:** General\
**Created:** [11 January 2020 13:27 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192 "2020-01-11T13:27:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 13:27 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/1 "2020-01-11T13:27:16Z")

</div>

I have previously used `node-red-contrib-webhookrelay` which is really easy to set up and use, although it is a 'paid for' service if you make more than 150 webhook calls per month.

Another forum post inspired me to try and setup a webhook connection **between 2 different servers** without using webhookrelay, but searching the forum, youtube and even google failed to produce any tutorial or guide how to do this.  
I did find [this flow](https://flows.nodered.org/flow/8666510f94ad422e4765) which @dceejay wrote, but found it difficult to translate into having client/server on different instances.

Can it be done within the node-RED environment, and if so, has anyone an example?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 January 2020 13:37 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/2 "2020-01-11T13:37:32Z")

</div>

A webhook is just a fancy name for an http request.

So you need an HTTP In node to create and endpoint that will listen for incoming requests.

And then use the HTTP Request node to send a request. This node will need to be configured with the full address of the instance with the HTTP In node on.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 14:22 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/3 "2020-01-11T14:22:03Z")

</div>

Aah right.  
I assume that the HTTP Request node will need the URL formatting as;  
`https://username:password@mysite.co.uk:1880/test`  
...where `test` is the endpoint.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 January 2020 14:52 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/4 "2020-01-11T14:52:09Z")

</div>

Yes, although you wouldn't typically put the username and password into the URL when the node has fields for those things which will store them securely in your credentials file

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 19:01 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/5 "2020-01-11T19:01:55Z")

</div>

Ah yes.  
Just tried it using the flows as per the gif below, and the client reliable receives the data from the server, but after a few seconds, I start to see errors being logged on the server instance. (Yet the client still continues to receive the data).  
Is this how the flows should be structured?

![httpgif2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9bcb5fd73c3a86d1d3ba1b7e97a9ede948d134ae.gif)

![http_error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03a18ddddcf21f81a570c791b97f408e1d792c76.jpeg)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 20:32 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/6 "2020-01-11T20:32:31Z")

</div>

Or do I need to hang a `http response` node onto the 'client' `http in` node to return the status code? That seems to stop the error messages.

![http_result](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/998e3cfe34f5851d106010183f5dc96204940dc7.jpeg)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 January 2020 20:36 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/7 "2020-01-11T20:36:06Z")

</div>

yes you must always have a response to an http in node... (you can of course vary what you send back...)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 January 2020 20:53 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/8 "2020-01-11T20:53:46Z")

</div>

And since it seems to be my lot in life to repeat warnings about security:

- As Nick says, don't put id/password into a URL as it may expose it to intermediaries and caches.
- When passing id/password (in a POST body of course, not in the URL), **ALWAYS** use HTTPS. Otherwise you are leaking credentials to who knows where.

Both are issues reduced if both servers are on a local network of course but it is good practice to assume that the bad people have access to your network (it is more common than many people realise).

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 21:06 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/9 "2020-01-11T21:06:43Z")

</div>

> [@TotallyInformation](#):
>
> And since it seems to be my lot in life to repeat warnings about security:

It's going to be a SSL connection, but thought it better to get it working without SSL first, and then introduce SSL once I get that working.

Are you sure that **my**  **interpretation** above, of Nick's advice, is a 'webhook' connection??  
I haven't used a websocket node anywhere, and haven't used URL's starting `ws://myserver.co....`  
It's not how I imagined a websocket flow would look like (but what do I know 🤔)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 January 2020 22:20 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/10 "2020-01-11T22:20:12Z")

</div>

Webhooks have nothing to do with websockets. They are http requests.

> **[Webhook](https://en.m.wikipedia.org/wiki/Webhook)**
>
> A webhook in web development is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Jeff Lindsay in 2007 from the computer programming term hook.
> The format is usually JSON. The request is done as a HTTP POST request. The receiving endp...

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2020 22:34 UTC](https://discourse.nodered.org/t/setting-up-webhook-connection-between-2-servers/20192/11 "2020-01-11T22:34:40Z")

</div>

Thanks. I wasn't disputing your advice, I just wasn't sure that I'd interpreted it correctly, and would not wish to leave a forum post that others may look at in the future, that was inaccurate or misleading.  
When you know how, it was ridiculously easy to set up, which again concerned me!!

Now engaged SSL, and all is good.

Thanks for the help.
