aiohttp-json-rpc with aiohttp periodicaly throws exception “invalid HTTP method”












0















I am using:



aiohttp==3.4.4
aiohttp-json-rpc==0.11.2
Python 3.7.1


I wrote simple json rpc client and server. The problem is that server periodicaly throws exception. It continue working, but exception from time to time appear is console:



How can I fix it?



Error handling request
Traceback (most recent call last):
File "/home/se7en/.pyenv/versions/3.7.1/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 242, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method


server.py



from aiohttp import web
import sys
from aiohttp.web import Application
from aiohttp_json_rpc import JsonRpc
import asyncio

from aiohttp_json_rpc.communicaton import JsonRpcRequest


async def ping(request):
print(type(request))
print('called')
print(request.params)
return 'pong'


if __name__ == '__main__':
loop = asyncio.get_event_loop()

rpc = JsonRpc()
rpc.add_methods(
('', ping),
)

app = Application()
app.router.add_route('*', '/', rpc)

#handler = app.make_handler()
app.router.add_get('/ping', ping)

#server = loop.run_until_complete(
# loop.create_server(handler, '0.0.0.0', 8080))

web.run_app(app, host='0.0.0.0', port=8080)
#loop.run_forever()


client.py



import asyncio
from aiohttp_json_rpc import JsonRpcClient


async def ping_json_rpc():
"""Connect to ws://localhost:8080/rpc, call ping() and disconnect."""
rpc_client = JsonRpcClient()
try:
await rpc_client.connect('0.0.0.0', 8080, '/')
call_result = await rpc_client.call('ping', params={'x':1,'y':2})
print(call_result) # prints 'pong' (if that's return val of ping)
call_result = await rpc_client.call('get_methods')
print(call_result)
finally:
await rpc_client.disconnect()


asyncio.get_event_loop().run_until_complete(ping_json_rpc())









share|improve this question



























    0















    I am using:



    aiohttp==3.4.4
    aiohttp-json-rpc==0.11.2
    Python 3.7.1


    I wrote simple json rpc client and server. The problem is that server periodicaly throws exception. It continue working, but exception from time to time appear is console:



    How can I fix it?



    Error handling request
    Traceback (most recent call last):
    File "/home/se7en/.pyenv/versions/3.7.1/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 242, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
    File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
    aiohttp.http_exceptions.BadStatusLine: invalid HTTP method


    server.py



    from aiohttp import web
    import sys
    from aiohttp.web import Application
    from aiohttp_json_rpc import JsonRpc
    import asyncio

    from aiohttp_json_rpc.communicaton import JsonRpcRequest


    async def ping(request):
    print(type(request))
    print('called')
    print(request.params)
    return 'pong'


    if __name__ == '__main__':
    loop = asyncio.get_event_loop()

    rpc = JsonRpc()
    rpc.add_methods(
    ('', ping),
    )

    app = Application()
    app.router.add_route('*', '/', rpc)

    #handler = app.make_handler()
    app.router.add_get('/ping', ping)

    #server = loop.run_until_complete(
    # loop.create_server(handler, '0.0.0.0', 8080))

    web.run_app(app, host='0.0.0.0', port=8080)
    #loop.run_forever()


    client.py



    import asyncio
    from aiohttp_json_rpc import JsonRpcClient


    async def ping_json_rpc():
    """Connect to ws://localhost:8080/rpc, call ping() and disconnect."""
    rpc_client = JsonRpcClient()
    try:
    await rpc_client.connect('0.0.0.0', 8080, '/')
    call_result = await rpc_client.call('ping', params={'x':1,'y':2})
    print(call_result) # prints 'pong' (if that's return val of ping)
    call_result = await rpc_client.call('get_methods')
    print(call_result)
    finally:
    await rpc_client.disconnect()


    asyncio.get_event_loop().run_until_complete(ping_json_rpc())









    share|improve this question

























      0












      0








      0








      I am using:



      aiohttp==3.4.4
      aiohttp-json-rpc==0.11.2
      Python 3.7.1


      I wrote simple json rpc client and server. The problem is that server periodicaly throws exception. It continue working, but exception from time to time appear is console:



      How can I fix it?



      Error handling request
      Traceback (most recent call last):
      File "/home/se7en/.pyenv/versions/3.7.1/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 242, in data_received
      messages, upgraded, tail = self._request_parser.feed_data(data)
      File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
      aiohttp.http_exceptions.BadStatusLine: invalid HTTP method


      server.py



      from aiohttp import web
      import sys
      from aiohttp.web import Application
      from aiohttp_json_rpc import JsonRpc
      import asyncio

      from aiohttp_json_rpc.communicaton import JsonRpcRequest


      async def ping(request):
      print(type(request))
      print('called')
      print(request.params)
      return 'pong'


      if __name__ == '__main__':
      loop = asyncio.get_event_loop()

      rpc = JsonRpc()
      rpc.add_methods(
      ('', ping),
      )

      app = Application()
      app.router.add_route('*', '/', rpc)

      #handler = app.make_handler()
      app.router.add_get('/ping', ping)

      #server = loop.run_until_complete(
      # loop.create_server(handler, '0.0.0.0', 8080))

      web.run_app(app, host='0.0.0.0', port=8080)
      #loop.run_forever()


      client.py



      import asyncio
      from aiohttp_json_rpc import JsonRpcClient


      async def ping_json_rpc():
      """Connect to ws://localhost:8080/rpc, call ping() and disconnect."""
      rpc_client = JsonRpcClient()
      try:
      await rpc_client.connect('0.0.0.0', 8080, '/')
      call_result = await rpc_client.call('ping', params={'x':1,'y':2})
      print(call_result) # prints 'pong' (if that's return val of ping)
      call_result = await rpc_client.call('get_methods')
      print(call_result)
      finally:
      await rpc_client.disconnect()


      asyncio.get_event_loop().run_until_complete(ping_json_rpc())









      share|improve this question














      I am using:



      aiohttp==3.4.4
      aiohttp-json-rpc==0.11.2
      Python 3.7.1


      I wrote simple json rpc client and server. The problem is that server periodicaly throws exception. It continue working, but exception from time to time appear is console:



      How can I fix it?



      Error handling request
      Traceback (most recent call last):
      File "/home/se7en/.pyenv/versions/3.7.1/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 242, in data_received
      messages, upgraded, tail = self._request_parser.feed_data(data)
      File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
      aiohttp.http_exceptions.BadStatusLine: invalid HTTP method


      server.py



      from aiohttp import web
      import sys
      from aiohttp.web import Application
      from aiohttp_json_rpc import JsonRpc
      import asyncio

      from aiohttp_json_rpc.communicaton import JsonRpcRequest


      async def ping(request):
      print(type(request))
      print('called')
      print(request.params)
      return 'pong'


      if __name__ == '__main__':
      loop = asyncio.get_event_loop()

      rpc = JsonRpc()
      rpc.add_methods(
      ('', ping),
      )

      app = Application()
      app.router.add_route('*', '/', rpc)

      #handler = app.make_handler()
      app.router.add_get('/ping', ping)

      #server = loop.run_until_complete(
      # loop.create_server(handler, '0.0.0.0', 8080))

      web.run_app(app, host='0.0.0.0', port=8080)
      #loop.run_forever()


      client.py



      import asyncio
      from aiohttp_json_rpc import JsonRpcClient


      async def ping_json_rpc():
      """Connect to ws://localhost:8080/rpc, call ping() and disconnect."""
      rpc_client = JsonRpcClient()
      try:
      await rpc_client.connect('0.0.0.0', 8080, '/')
      call_result = await rpc_client.call('ping', params={'x':1,'y':2})
      print(call_result) # prints 'pong' (if that's return val of ping)
      call_result = await rpc_client.call('get_methods')
      print(call_result)
      finally:
      await rpc_client.disconnect()


      asyncio.get_event_loop().run_until_complete(ping_json_rpc())






      aiohttp python-3.7






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 6:15









      EvgEvg

      1,07342549




      1,07342549
























          0






          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',
          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%2f53441482%2faiohttp-json-rpc-with-aiohttp-periodicaly-throws-exception-invalid-http-method%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441482%2faiohttp-json-rpc-with-aiohttp-periodicaly-throws-exception-invalid-http-method%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'