Python Autobahn Websocket Server Receving One connection at a time












0















Python Asyncio or Twisted used by Autobahn are supposed to Handle concurrent connection at the same time.
I followed a good tutorial on autobahn read-the-doc, it all worked well, yet the server is receiving only one connection and process it's request and then after that accept a second one.



How can I ensure that the server receives multiple connection cocurrently without holding other connecting peer?



I have searched across the web the whole day but no success
here is my code(I have cut out a lot of code while debugging)



from autobahn.asyncio.websocket import WebSocketServerProtocol
from autobahn.asyncio.websocket import WebSocketServerFactory

class NMmapperServerProtocol(WebSocketServerProtocol):
cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

def onMessage(self, payload, isBinary):
"""
@payload the message
@isBinary whether it's a binary message
"""
try:
offload_payload = json.loads(payload.decode("utf-8"))
await asyncio.gather(cmd.processWSCommands(offload_payload, self))
except Exception as e:
raise

def onConnect(self, request):
"""
When we've got a peer connect to our server
"""
try:
#print(self)
print(request.peer, "Has connected")
except Exception as e:
raise

def onOpen(self):
"""
We have a fully connection
"""
try:
# Some database action can be made from here
print("Connection now opened")
except Exception as e:
raise

def onClose(self, wasClean, code, reason):
"""
@ the client is closing his or her
connection
"""
try:
print("wasClean ", wasClean)
print("code ", code)
print("reason ", reason)
except Exception as e:
raise

# Setters
def setCsrftoken(self, cookie_string):
"""
@ parse an set
"""
self.csrftoken = self.parse_csrftoken(cookie_string)

# Setters
def setSession(self, cookie_string):
"""
@ parse an set
"""
self.session = self.parse_session(cookie_string)


if __name__=="__main__":
if(IN_PRODUCTION):
print("RUNNING ")
factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
factory.run_loop()
else:
print("Running on dev")
factory = WebSocketServerFactory()
factory.protocol = NMmapperServerProtocol

loop = asyncio.get_event_loop()
coro = loop.create_server(factory, '0.0.0.0', 9000)
server = loop.run_until_complete(coro)

try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
server.close()
loop.close()


Thank you.










share|improve this question



























    0















    Python Asyncio or Twisted used by Autobahn are supposed to Handle concurrent connection at the same time.
    I followed a good tutorial on autobahn read-the-doc, it all worked well, yet the server is receiving only one connection and process it's request and then after that accept a second one.



    How can I ensure that the server receives multiple connection cocurrently without holding other connecting peer?



    I have searched across the web the whole day but no success
    here is my code(I have cut out a lot of code while debugging)



    from autobahn.asyncio.websocket import WebSocketServerProtocol
    from autobahn.asyncio.websocket import WebSocketServerFactory

    class NMmapperServerProtocol(WebSocketServerProtocol):
    cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

    def onMessage(self, payload, isBinary):
    """
    @payload the message
    @isBinary whether it's a binary message
    """
    try:
    offload_payload = json.loads(payload.decode("utf-8"))
    await asyncio.gather(cmd.processWSCommands(offload_payload, self))
    except Exception as e:
    raise

    def onConnect(self, request):
    """
    When we've got a peer connect to our server
    """
    try:
    #print(self)
    print(request.peer, "Has connected")
    except Exception as e:
    raise

    def onOpen(self):
    """
    We have a fully connection
    """
    try:
    # Some database action can be made from here
    print("Connection now opened")
    except Exception as e:
    raise

    def onClose(self, wasClean, code, reason):
    """
    @ the client is closing his or her
    connection
    """
    try:
    print("wasClean ", wasClean)
    print("code ", code)
    print("reason ", reason)
    except Exception as e:
    raise

    # Setters
    def setCsrftoken(self, cookie_string):
    """
    @ parse an set
    """
    self.csrftoken = self.parse_csrftoken(cookie_string)

    # Setters
    def setSession(self, cookie_string):
    """
    @ parse an set
    """
    self.session = self.parse_session(cookie_string)


    if __name__=="__main__":
    if(IN_PRODUCTION):
    print("RUNNING ")
    factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
    factory.run_loop()
    else:
    print("Running on dev")
    factory = WebSocketServerFactory()
    factory.protocol = NMmapperServerProtocol

    loop = asyncio.get_event_loop()
    coro = loop.create_server(factory, '0.0.0.0', 9000)
    server = loop.run_until_complete(coro)

    try:
    loop.run_forever()
    except KeyboardInterrupt:
    pass
    finally:
    server.close()
    loop.close()


    Thank you.










    share|improve this question

























      0












      0








      0








      Python Asyncio or Twisted used by Autobahn are supposed to Handle concurrent connection at the same time.
      I followed a good tutorial on autobahn read-the-doc, it all worked well, yet the server is receiving only one connection and process it's request and then after that accept a second one.



      How can I ensure that the server receives multiple connection cocurrently without holding other connecting peer?



      I have searched across the web the whole day but no success
      here is my code(I have cut out a lot of code while debugging)



      from autobahn.asyncio.websocket import WebSocketServerProtocol
      from autobahn.asyncio.websocket import WebSocketServerFactory

      class NMmapperServerProtocol(WebSocketServerProtocol):
      cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

      def onMessage(self, payload, isBinary):
      """
      @payload the message
      @isBinary whether it's a binary message
      """
      try:
      offload_payload = json.loads(payload.decode("utf-8"))
      await asyncio.gather(cmd.processWSCommands(offload_payload, self))
      except Exception as e:
      raise

      def onConnect(self, request):
      """
      When we've got a peer connect to our server
      """
      try:
      #print(self)
      print(request.peer, "Has connected")
      except Exception as e:
      raise

      def onOpen(self):
      """
      We have a fully connection
      """
      try:
      # Some database action can be made from here
      print("Connection now opened")
      except Exception as e:
      raise

      def onClose(self, wasClean, code, reason):
      """
      @ the client is closing his or her
      connection
      """
      try:
      print("wasClean ", wasClean)
      print("code ", code)
      print("reason ", reason)
      except Exception as e:
      raise

      # Setters
      def setCsrftoken(self, cookie_string):
      """
      @ parse an set
      """
      self.csrftoken = self.parse_csrftoken(cookie_string)

      # Setters
      def setSession(self, cookie_string):
      """
      @ parse an set
      """
      self.session = self.parse_session(cookie_string)


      if __name__=="__main__":
      if(IN_PRODUCTION):
      print("RUNNING ")
      factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
      factory.run_loop()
      else:
      print("Running on dev")
      factory = WebSocketServerFactory()
      factory.protocol = NMmapperServerProtocol

      loop = asyncio.get_event_loop()
      coro = loop.create_server(factory, '0.0.0.0', 9000)
      server = loop.run_until_complete(coro)

      try:
      loop.run_forever()
      except KeyboardInterrupt:
      pass
      finally:
      server.close()
      loop.close()


      Thank you.










      share|improve this question














      Python Asyncio or Twisted used by Autobahn are supposed to Handle concurrent connection at the same time.
      I followed a good tutorial on autobahn read-the-doc, it all worked well, yet the server is receiving only one connection and process it's request and then after that accept a second one.



      How can I ensure that the server receives multiple connection cocurrently without holding other connecting peer?



      I have searched across the web the whole day but no success
      here is my code(I have cut out a lot of code while debugging)



      from autobahn.asyncio.websocket import WebSocketServerProtocol
      from autobahn.asyncio.websocket import WebSocketServerFactory

      class NMmapperServerProtocol(WebSocketServerProtocol):
      cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

      def onMessage(self, payload, isBinary):
      """
      @payload the message
      @isBinary whether it's a binary message
      """
      try:
      offload_payload = json.loads(payload.decode("utf-8"))
      await asyncio.gather(cmd.processWSCommands(offload_payload, self))
      except Exception as e:
      raise

      def onConnect(self, request):
      """
      When we've got a peer connect to our server
      """
      try:
      #print(self)
      print(request.peer, "Has connected")
      except Exception as e:
      raise

      def onOpen(self):
      """
      We have a fully connection
      """
      try:
      # Some database action can be made from here
      print("Connection now opened")
      except Exception as e:
      raise

      def onClose(self, wasClean, code, reason):
      """
      @ the client is closing his or her
      connection
      """
      try:
      print("wasClean ", wasClean)
      print("code ", code)
      print("reason ", reason)
      except Exception as e:
      raise

      # Setters
      def setCsrftoken(self, cookie_string):
      """
      @ parse an set
      """
      self.csrftoken = self.parse_csrftoken(cookie_string)

      # Setters
      def setSession(self, cookie_string):
      """
      @ parse an set
      """
      self.session = self.parse_session(cookie_string)


      if __name__=="__main__":
      if(IN_PRODUCTION):
      print("RUNNING ")
      factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
      factory.run_loop()
      else:
      print("Running on dev")
      factory = WebSocketServerFactory()
      factory.protocol = NMmapperServerProtocol

      loop = asyncio.get_event_loop()
      coro = loop.create_server(factory, '0.0.0.0', 9000)
      server = loop.run_until_complete(coro)

      try:
      loop.run_forever()
      except KeyboardInterrupt:
      pass
      finally:
      server.close()
      loop.close()


      Thank you.







      websocket autobahn






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 17:57









      Wangolo JoelWangolo Joel

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I finally got it working as expected. Being an asyncio library
          i had to prefix async on each method that performs long running task



          The Problem was with the onMessage, I had to process the messages in parallel
          not to block the other clients wanting to process there messages also.
          so to do that i had to



          offload_payload = json.loads(payload.decode("utf-8"))
          loop = asyncio.get_event_loop()

          # Offload command processing
          loop.create_task(self.processWSCommands(offload_payload, self))


          This way every message is processed in parallel
          Even in such an instance ensure that the method or function processing the message don't block.



          from autobahn.asyncio.websocket import WebSocketServerProtocol
          from autobahn.asyncio.websocket import WebSocketServerFactory

          class NMmapperServerProtocol(WebSocketServerProtocol):
          cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

          async def onMessage(self, payload, isBinary):
          """
          @payload the message
          @isBinary whether it's a binary message
          """
          try:
          offload_payload = json.loads(payload.decode("utf-8"))
          loop = asyncio.get_event_loop()
          #loop.create_task(runner(10, self.peer))
          #asyncio.gather(runner(20, self.peer))

          # Offload command processing
          loop.create_task(self.processWSCommands(offload_payload, self))
          except Exception as e:
          raise

          def onConnect(self, request):
          """
          When we've got a peer connect to our server
          """
          try:
          #print(self)
          print(request.peer, "Has connected")
          except Exception as e:
          raise

          def onOpen(self):
          """
          We have a fully connection
          """
          try:
          # Some database action can be made from here
          print("Connection now opened")
          except Exception as e:
          raise

          def onClose(self, wasClean, code, reason):
          """
          @ the client is closing his or her
          connection
          """
          try:
          print("wasClean ", wasClean)
          print("code ", code)
          print("reason ", reason)
          except Exception as e:
          raise

          # Setters
          def setCsrftoken(self, cookie_string):
          """
          @ parse an set
          """
          self.csrftoken = self.parse_csrftoken(cookie_string)

          # Setters
          def setSession(self, cookie_string):
          """
          @ parse an set
          """
          self.session = self.parse_session(cookie_string)


          if __name__=="__main__":
          if(IN_PRODUCTION):
          print("RUNNING ")
          factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
          factory.run_loop()
          else:
          print("Running on dev")
          factory = WebSocketServerFactory()
          factory.protocol = NMmapperServerProtocol

          loop = asyncio.get_event_loop()
          coro = loop.create_server(factory, '0.0.0.0', 9000)
          server = loop.run_until_complete(coro)

          try:
          loop.run_forever()
          except KeyboardInterrupt:
          pass
          finally:
          server.close()
          loop.close()





          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%2f53418006%2fpython-autobahn-websocket-server-receving-one-connection-at-a-time%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














            I finally got it working as expected. Being an asyncio library
            i had to prefix async on each method that performs long running task



            The Problem was with the onMessage, I had to process the messages in parallel
            not to block the other clients wanting to process there messages also.
            so to do that i had to



            offload_payload = json.loads(payload.decode("utf-8"))
            loop = asyncio.get_event_loop()

            # Offload command processing
            loop.create_task(self.processWSCommands(offload_payload, self))


            This way every message is processed in parallel
            Even in such an instance ensure that the method or function processing the message don't block.



            from autobahn.asyncio.websocket import WebSocketServerProtocol
            from autobahn.asyncio.websocket import WebSocketServerFactory

            class NMmapperServerProtocol(WebSocketServerProtocol):
            cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

            async def onMessage(self, payload, isBinary):
            """
            @payload the message
            @isBinary whether it's a binary message
            """
            try:
            offload_payload = json.loads(payload.decode("utf-8"))
            loop = asyncio.get_event_loop()
            #loop.create_task(runner(10, self.peer))
            #asyncio.gather(runner(20, self.peer))

            # Offload command processing
            loop.create_task(self.processWSCommands(offload_payload, self))
            except Exception as e:
            raise

            def onConnect(self, request):
            """
            When we've got a peer connect to our server
            """
            try:
            #print(self)
            print(request.peer, "Has connected")
            except Exception as e:
            raise

            def onOpen(self):
            """
            We have a fully connection
            """
            try:
            # Some database action can be made from here
            print("Connection now opened")
            except Exception as e:
            raise

            def onClose(self, wasClean, code, reason):
            """
            @ the client is closing his or her
            connection
            """
            try:
            print("wasClean ", wasClean)
            print("code ", code)
            print("reason ", reason)
            except Exception as e:
            raise

            # Setters
            def setCsrftoken(self, cookie_string):
            """
            @ parse an set
            """
            self.csrftoken = self.parse_csrftoken(cookie_string)

            # Setters
            def setSession(self, cookie_string):
            """
            @ parse an set
            """
            self.session = self.parse_session(cookie_string)


            if __name__=="__main__":
            if(IN_PRODUCTION):
            print("RUNNING ")
            factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
            factory.run_loop()
            else:
            print("Running on dev")
            factory = WebSocketServerFactory()
            factory.protocol = NMmapperServerProtocol

            loop = asyncio.get_event_loop()
            coro = loop.create_server(factory, '0.0.0.0', 9000)
            server = loop.run_until_complete(coro)

            try:
            loop.run_forever()
            except KeyboardInterrupt:
            pass
            finally:
            server.close()
            loop.close()





            share|improve this answer




























              0














              I finally got it working as expected. Being an asyncio library
              i had to prefix async on each method that performs long running task



              The Problem was with the onMessage, I had to process the messages in parallel
              not to block the other clients wanting to process there messages also.
              so to do that i had to



              offload_payload = json.loads(payload.decode("utf-8"))
              loop = asyncio.get_event_loop()

              # Offload command processing
              loop.create_task(self.processWSCommands(offload_payload, self))


              This way every message is processed in parallel
              Even in such an instance ensure that the method or function processing the message don't block.



              from autobahn.asyncio.websocket import WebSocketServerProtocol
              from autobahn.asyncio.websocket import WebSocketServerFactory

              class NMmapperServerProtocol(WebSocketServerProtocol):
              cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

              async def onMessage(self, payload, isBinary):
              """
              @payload the message
              @isBinary whether it's a binary message
              """
              try:
              offload_payload = json.loads(payload.decode("utf-8"))
              loop = asyncio.get_event_loop()
              #loop.create_task(runner(10, self.peer))
              #asyncio.gather(runner(20, self.peer))

              # Offload command processing
              loop.create_task(self.processWSCommands(offload_payload, self))
              except Exception as e:
              raise

              def onConnect(self, request):
              """
              When we've got a peer connect to our server
              """
              try:
              #print(self)
              print(request.peer, "Has connected")
              except Exception as e:
              raise

              def onOpen(self):
              """
              We have a fully connection
              """
              try:
              # Some database action can be made from here
              print("Connection now opened")
              except Exception as e:
              raise

              def onClose(self, wasClean, code, reason):
              """
              @ the client is closing his or her
              connection
              """
              try:
              print("wasClean ", wasClean)
              print("code ", code)
              print("reason ", reason)
              except Exception as e:
              raise

              # Setters
              def setCsrftoken(self, cookie_string):
              """
              @ parse an set
              """
              self.csrftoken = self.parse_csrftoken(cookie_string)

              # Setters
              def setSession(self, cookie_string):
              """
              @ parse an set
              """
              self.session = self.parse_session(cookie_string)


              if __name__=="__main__":
              if(IN_PRODUCTION):
              print("RUNNING ")
              factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
              factory.run_loop()
              else:
              print("Running on dev")
              factory = WebSocketServerFactory()
              factory.protocol = NMmapperServerProtocol

              loop = asyncio.get_event_loop()
              coro = loop.create_server(factory, '0.0.0.0', 9000)
              server = loop.run_until_complete(coro)

              try:
              loop.run_forever()
              except KeyboardInterrupt:
              pass
              finally:
              server.close()
              loop.close()





              share|improve this answer


























                0












                0








                0







                I finally got it working as expected. Being an asyncio library
                i had to prefix async on each method that performs long running task



                The Problem was with the onMessage, I had to process the messages in parallel
                not to block the other clients wanting to process there messages also.
                so to do that i had to



                offload_payload = json.loads(payload.decode("utf-8"))
                loop = asyncio.get_event_loop()

                # Offload command processing
                loop.create_task(self.processWSCommands(offload_payload, self))


                This way every message is processed in parallel
                Even in such an instance ensure that the method or function processing the message don't block.



                from autobahn.asyncio.websocket import WebSocketServerProtocol
                from autobahn.asyncio.websocket import WebSocketServerFactory

                class NMmapperServerProtocol(WebSocketServerProtocol):
                cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

                async def onMessage(self, payload, isBinary):
                """
                @payload the message
                @isBinary whether it's a binary message
                """
                try:
                offload_payload = json.loads(payload.decode("utf-8"))
                loop = asyncio.get_event_loop()
                #loop.create_task(runner(10, self.peer))
                #asyncio.gather(runner(20, self.peer))

                # Offload command processing
                loop.create_task(self.processWSCommands(offload_payload, self))
                except Exception as e:
                raise

                def onConnect(self, request):
                """
                When we've got a peer connect to our server
                """
                try:
                #print(self)
                print(request.peer, "Has connected")
                except Exception as e:
                raise

                def onOpen(self):
                """
                We have a fully connection
                """
                try:
                # Some database action can be made from here
                print("Connection now opened")
                except Exception as e:
                raise

                def onClose(self, wasClean, code, reason):
                """
                @ the client is closing his or her
                connection
                """
                try:
                print("wasClean ", wasClean)
                print("code ", code)
                print("reason ", reason)
                except Exception as e:
                raise

                # Setters
                def setCsrftoken(self, cookie_string):
                """
                @ parse an set
                """
                self.csrftoken = self.parse_csrftoken(cookie_string)

                # Setters
                def setSession(self, cookie_string):
                """
                @ parse an set
                """
                self.session = self.parse_session(cookie_string)


                if __name__=="__main__":
                if(IN_PRODUCTION):
                print("RUNNING ")
                factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
                factory.run_loop()
                else:
                print("Running on dev")
                factory = WebSocketServerFactory()
                factory.protocol = NMmapperServerProtocol

                loop = asyncio.get_event_loop()
                coro = loop.create_server(factory, '0.0.0.0', 9000)
                server = loop.run_until_complete(coro)

                try:
                loop.run_forever()
                except KeyboardInterrupt:
                pass
                finally:
                server.close()
                loop.close()





                share|improve this answer













                I finally got it working as expected. Being an asyncio library
                i had to prefix async on each method that performs long running task



                The Problem was with the onMessage, I had to process the messages in parallel
                not to block the other clients wanting to process there messages also.
                so to do that i had to



                offload_payload = json.loads(payload.decode("utf-8"))
                loop = asyncio.get_event_loop()

                # Offload command processing
                loop.create_task(self.processWSCommands(offload_payload, self))


                This way every message is processed in parallel
                Even in such an instance ensure that the method or function processing the message don't block.



                from autobahn.asyncio.websocket import WebSocketServerProtocol
                from autobahn.asyncio.websocket import WebSocketServerFactory

                class NMmapperServerProtocol(WebSocketServerProtocol):
                cmd = NMmapperWSCommandParser() # I have cut out this due to debugging

                async def onMessage(self, payload, isBinary):
                """
                @payload the message
                @isBinary whether it's a binary message
                """
                try:
                offload_payload = json.loads(payload.decode("utf-8"))
                loop = asyncio.get_event_loop()
                #loop.create_task(runner(10, self.peer))
                #asyncio.gather(runner(20, self.peer))

                # Offload command processing
                loop.create_task(self.processWSCommands(offload_payload, self))
                except Exception as e:
                raise

                def onConnect(self, request):
                """
                When we've got a peer connect to our server
                """
                try:
                #print(self)
                print(request.peer, "Has connected")
                except Exception as e:
                raise

                def onOpen(self):
                """
                We have a fully connection
                """
                try:
                # Some database action can be made from here
                print("Connection now opened")
                except Exception as e:
                raise

                def onClose(self, wasClean, code, reason):
                """
                @ the client is closing his or her
                connection
                """
                try:
                print("wasClean ", wasClean)
                print("code ", code)
                print("reason ", reason)
                except Exception as e:
                raise

                # Setters
                def setCsrftoken(self, cookie_string):
                """
                @ parse an set
                """
                self.csrftoken = self.parse_csrftoken(cookie_string)

                # Setters
                def setSession(self, cookie_string):
                """
                @ parse an set
                """
                self.session = self.parse_session(cookie_string)


                if __name__=="__main__":
                if(IN_PRODUCTION):
                print("RUNNING ")
                factory = NMmapperWSServerFactory(PRODUCTION_HOST, PRODUCTION_PORT)
                factory.run_loop()
                else:
                print("Running on dev")
                factory = WebSocketServerFactory()
                factory.protocol = NMmapperServerProtocol

                loop = asyncio.get_event_loop()
                coro = loop.create_server(factory, '0.0.0.0', 9000)
                server = loop.run_until_complete(coro)

                try:
                loop.run_forever()
                except KeyboardInterrupt:
                pass
                finally:
                server.close()
                loop.close()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 6:14









                Wangolo JoelWangolo Joel

                1




                1
































                    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%2f53418006%2fpython-autobahn-websocket-server-receving-one-connection-at-a-time%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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    Npm cannot find a required file even through it is in the searched directory