What port is used to send request by an Express app?










0















I have an Express app A, that is configured to listen on 4455 port.



The app also uses axios to send requests to a different server B.



The server B is configured such that it replies to host:port from which it recieved the request.
In this case server A can't recieve response from B, because in the request the, port of A keeps changing.



Does express server send and receive messages from the same port?










share|improve this question






















  • Does that mean that server B makes a new connection to host:port to send its response?

    – robertklep
    Nov 13 '18 at 11:10











  • @robertklep: yes.

    – Lakshya
    Nov 13 '18 at 12:54















0















I have an Express app A, that is configured to listen on 4455 port.



The app also uses axios to send requests to a different server B.



The server B is configured such that it replies to host:port from which it recieved the request.
In this case server A can't recieve response from B, because in the request the, port of A keeps changing.



Does express server send and receive messages from the same port?










share|improve this question






















  • Does that mean that server B makes a new connection to host:port to send its response?

    – robertklep
    Nov 13 '18 at 11:10











  • @robertklep: yes.

    – Lakshya
    Nov 13 '18 at 12:54













0












0








0








I have an Express app A, that is configured to listen on 4455 port.



The app also uses axios to send requests to a different server B.



The server B is configured such that it replies to host:port from which it recieved the request.
In this case server A can't recieve response from B, because in the request the, port of A keeps changing.



Does express server send and receive messages from the same port?










share|improve this question














I have an Express app A, that is configured to listen on 4455 port.



The app also uses axios to send requests to a different server B.



The server B is configured such that it replies to host:port from which it recieved the request.
In this case server A can't recieve response from B, because in the request the, port of A keeps changing.



Does express server send and receive messages from the same port?







node.js express axios






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 10:17









LakshyaLakshya

103




103












  • Does that mean that server B makes a new connection to host:port to send its response?

    – robertklep
    Nov 13 '18 at 11:10











  • @robertklep: yes.

    – Lakshya
    Nov 13 '18 at 12:54

















  • Does that mean that server B makes a new connection to host:port to send its response?

    – robertklep
    Nov 13 '18 at 11:10











  • @robertklep: yes.

    – Lakshya
    Nov 13 '18 at 12:54
















Does that mean that server B makes a new connection to host:port to send its response?

– robertklep
Nov 13 '18 at 11:10





Does that mean that server B makes a new connection to host:port to send its response?

– robertklep
Nov 13 '18 at 11:10













@robertklep: yes.

– Lakshya
Nov 13 '18 at 12:54





@robertklep: yes.

– Lakshya
Nov 13 '18 at 12:54












1 Answer
1






active

oldest

votes


















0














The port on which Express listens for incoming connections has nothing to do with the port used for requests that happen to be made from the same application.



Requests are typically made from a random(-ish) port, and it would require some effort if you want that port to be fixed (always the same). In fact, I'm not even sure if you can make axios use a specific local port from which it makes requests.



That leaves the following solution: you make a request using axios, somehow (I'm not sure how) record from which local port that request is being made, and after the request has finished, create a temporary (Express) server that listens for the response on that same local port. When server B has sent its response (or after a specific timeout), that server is stopped.



To be honest, the way that server B sends back its responses is quite uncommon, especially since requests are almost always made from a random port. I also don't understand why server B cannot send back the response over the existing connection.






share|improve this answer






















    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',
    autoActivateHeartbeat: false,
    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%2f53278718%2fwhat-port-is-used-to-send-request-by-an-express-app%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The port on which Express listens for incoming connections has nothing to do with the port used for requests that happen to be made from the same application.



    Requests are typically made from a random(-ish) port, and it would require some effort if you want that port to be fixed (always the same). In fact, I'm not even sure if you can make axios use a specific local port from which it makes requests.



    That leaves the following solution: you make a request using axios, somehow (I'm not sure how) record from which local port that request is being made, and after the request has finished, create a temporary (Express) server that listens for the response on that same local port. When server B has sent its response (or after a specific timeout), that server is stopped.



    To be honest, the way that server B sends back its responses is quite uncommon, especially since requests are almost always made from a random port. I also don't understand why server B cannot send back the response over the existing connection.






    share|improve this answer



























      0














      The port on which Express listens for incoming connections has nothing to do with the port used for requests that happen to be made from the same application.



      Requests are typically made from a random(-ish) port, and it would require some effort if you want that port to be fixed (always the same). In fact, I'm not even sure if you can make axios use a specific local port from which it makes requests.



      That leaves the following solution: you make a request using axios, somehow (I'm not sure how) record from which local port that request is being made, and after the request has finished, create a temporary (Express) server that listens for the response on that same local port. When server B has sent its response (or after a specific timeout), that server is stopped.



      To be honest, the way that server B sends back its responses is quite uncommon, especially since requests are almost always made from a random port. I also don't understand why server B cannot send back the response over the existing connection.






      share|improve this answer

























        0












        0








        0







        The port on which Express listens for incoming connections has nothing to do with the port used for requests that happen to be made from the same application.



        Requests are typically made from a random(-ish) port, and it would require some effort if you want that port to be fixed (always the same). In fact, I'm not even sure if you can make axios use a specific local port from which it makes requests.



        That leaves the following solution: you make a request using axios, somehow (I'm not sure how) record from which local port that request is being made, and after the request has finished, create a temporary (Express) server that listens for the response on that same local port. When server B has sent its response (or after a specific timeout), that server is stopped.



        To be honest, the way that server B sends back its responses is quite uncommon, especially since requests are almost always made from a random port. I also don't understand why server B cannot send back the response over the existing connection.






        share|improve this answer













        The port on which Express listens for incoming connections has nothing to do with the port used for requests that happen to be made from the same application.



        Requests are typically made from a random(-ish) port, and it would require some effort if you want that port to be fixed (always the same). In fact, I'm not even sure if you can make axios use a specific local port from which it makes requests.



        That leaves the following solution: you make a request using axios, somehow (I'm not sure how) record from which local port that request is being made, and after the request has finished, create a temporary (Express) server that listens for the response on that same local port. When server B has sent its response (or after a specific timeout), that server is stopped.



        To be honest, the way that server B sends back its responses is quite uncommon, especially since requests are almost always made from a random port. I also don't understand why server B cannot send back the response over the existing connection.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 13:02









        robertkleprobertklep

        136k18234243




        136k18234243



























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278718%2fwhat-port-is-used-to-send-request-by-an-express-app%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







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands