How can a client in a LAN set a webhook?











up vote
-1
down vote

favorite












I have a question on webhook. I'm making some IoT device (an Arduino, for example) which controls my TV. The device is connecting to a router and owns a local IP address. In addition, I have a cloud server setup. To control the TV using my phone, all I can think of is to send a HTTP request to the server from the phone, saying "hey I want to turn on the TV." The server takes notes, and the next time (hopefully not very late after) the IoT device query the server for command, the server tells it that the mobile user wants to turn on the TV.



In order to implement this, the IoT device has to send HTTP request to the server very frequently, therefore consuming quite some battery energy. Recently I heard the idea of "Webhook", saying that instead of querying the server frequently, one can provide a URL to the server so that in case there is any command from the user (in this case, me on the mobile phone), the server can make an HTTP request to the client (in this case, the controlling device).



However, the problem for me is my controlling device only has a local IP, and without manually doing the port forwarding on the router, I don't know how it can own a URL accessable by another user not living in the same LAN. Is this achievable?



I also knew the "websocket" protocol but it seems to me that the server needs to maintain a TCP connection with every client. With little knowledge to it, I can tell whether it's more suitable for the task I described. (Potentially, there will be tens of thousands of users controlling their own TVs through one server on the cloud.)



Did I misunderstand the usage of webhook entirely? If not, how do we solve the local IP problem?



Thanks very much!










share|improve this question


























    up vote
    -1
    down vote

    favorite












    I have a question on webhook. I'm making some IoT device (an Arduino, for example) which controls my TV. The device is connecting to a router and owns a local IP address. In addition, I have a cloud server setup. To control the TV using my phone, all I can think of is to send a HTTP request to the server from the phone, saying "hey I want to turn on the TV." The server takes notes, and the next time (hopefully not very late after) the IoT device query the server for command, the server tells it that the mobile user wants to turn on the TV.



    In order to implement this, the IoT device has to send HTTP request to the server very frequently, therefore consuming quite some battery energy. Recently I heard the idea of "Webhook", saying that instead of querying the server frequently, one can provide a URL to the server so that in case there is any command from the user (in this case, me on the mobile phone), the server can make an HTTP request to the client (in this case, the controlling device).



    However, the problem for me is my controlling device only has a local IP, and without manually doing the port forwarding on the router, I don't know how it can own a URL accessable by another user not living in the same LAN. Is this achievable?



    I also knew the "websocket" protocol but it seems to me that the server needs to maintain a TCP connection with every client. With little knowledge to it, I can tell whether it's more suitable for the task I described. (Potentially, there will be tens of thousands of users controlling their own TVs through one server on the cloud.)



    Did I misunderstand the usage of webhook entirely? If not, how do we solve the local IP problem?



    Thanks very much!










    share|improve this question
























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I have a question on webhook. I'm making some IoT device (an Arduino, for example) which controls my TV. The device is connecting to a router and owns a local IP address. In addition, I have a cloud server setup. To control the TV using my phone, all I can think of is to send a HTTP request to the server from the phone, saying "hey I want to turn on the TV." The server takes notes, and the next time (hopefully not very late after) the IoT device query the server for command, the server tells it that the mobile user wants to turn on the TV.



      In order to implement this, the IoT device has to send HTTP request to the server very frequently, therefore consuming quite some battery energy. Recently I heard the idea of "Webhook", saying that instead of querying the server frequently, one can provide a URL to the server so that in case there is any command from the user (in this case, me on the mobile phone), the server can make an HTTP request to the client (in this case, the controlling device).



      However, the problem for me is my controlling device only has a local IP, and without manually doing the port forwarding on the router, I don't know how it can own a URL accessable by another user not living in the same LAN. Is this achievable?



      I also knew the "websocket" protocol but it seems to me that the server needs to maintain a TCP connection with every client. With little knowledge to it, I can tell whether it's more suitable for the task I described. (Potentially, there will be tens of thousands of users controlling their own TVs through one server on the cloud.)



      Did I misunderstand the usage of webhook entirely? If not, how do we solve the local IP problem?



      Thanks very much!










      share|improve this question













      I have a question on webhook. I'm making some IoT device (an Arduino, for example) which controls my TV. The device is connecting to a router and owns a local IP address. In addition, I have a cloud server setup. To control the TV using my phone, all I can think of is to send a HTTP request to the server from the phone, saying "hey I want to turn on the TV." The server takes notes, and the next time (hopefully not very late after) the IoT device query the server for command, the server tells it that the mobile user wants to turn on the TV.



      In order to implement this, the IoT device has to send HTTP request to the server very frequently, therefore consuming quite some battery energy. Recently I heard the idea of "Webhook", saying that instead of querying the server frequently, one can provide a URL to the server so that in case there is any command from the user (in this case, me on the mobile phone), the server can make an HTTP request to the client (in this case, the controlling device).



      However, the problem for me is my controlling device only has a local IP, and without manually doing the port forwarding on the router, I don't know how it can own a URL accessable by another user not living in the same LAN. Is this achievable?



      I also knew the "websocket" protocol but it seems to me that the server needs to maintain a TCP connection with every client. With little knowledge to it, I can tell whether it's more suitable for the task I described. (Potentially, there will be tens of thousands of users controlling their own TVs through one server on the cloud.)



      Did I misunderstand the usage of webhook entirely? If not, how do we solve the local IP problem?



      Thanks very much!







      http websocket iot webhooks






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 at 9:27









      Zheng Liu

      1568




      1568





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408883%2fhow-can-a-client-in-a-lan-set-a-webhook%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408883%2fhow-can-a-client-in-a-lan-set-a-webhook%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...