Code Monkey home page Code Monkey logo

Comments (13)

dayres avatar dayres commented on May 17, 2024

This may be related to an issue on the server being tested, but I would expect the test case to fail instead of throwing an exception.

Any advise would be appreciated.

from autobahn-testsuite.

oberstet avatar oberstet commented on May 17, 2024

The issue is likely triggered by the connection being terminated before the WebSocket opening handshake is even finished.

The test suite should of course be prepared to handle that as well, so it's (also) a bug in the test suite.

You might try to enable debugging with wstest by giving "-d" on command line .. maybe this sheds some light on why the server is dropping the TCP before even starting the handshake.

from autobahn-testsuite.

dayres avatar dayres commented on May 17, 2024

FYI, the debug option didn't give me any more information than without. I'll have to dig a bit deeper.

from autobahn-testsuite.

nesttaylor avatar nesttaylor commented on May 17, 2024

This is still a fairly serious issue as of 0.9.8.

from autobahn-testsuite.

tlynn avatar tlynn commented on May 17, 2024

This is what I'm using as a workaround:

diff --git a/autobahntestsuite/autobahntestsuite/case/case.py b/autobahntestsuite/autobahntestsuite/case/case.py
index c46c677..6977d90 100644
--- a/autobahntestsuite/autobahntestsuite/case/case.py
+++ b/autobahntestsuite/autobahntestsuite/case/case.py
@@ -39,7 +39,7 @@ class Case:
       self.p = protocol
       self.received = []
       self.expected = {}
-      self.expectedClose = {}
+      self.expectedClose = {'closedByMe': 'NOT SET'}
       self.behavior = Case.FAILED
       self.behaviorClose = Case.FAILED
       self.result = "Actual events differ from any expected."
diff --git a/autobahntestsuite/autobahntestsuite/case/case10_1_1.py b/autobahntestsuite/autobahntestsuite/case/case10_1_1.py
index 53e9eb6..4ead31c 100644
--- a/autobahntestsuite/autobahntestsuite/case/case10_1_1.py
+++ b/autobahntestsuite/autobahntestsuite/case/case10_1_1.py
@@ -35,11 +35,12 @@ class Case10_1_1(Case):
    def onConnectionLost(self, failedByMe):
       Case.onConnectionLost(self, failedByMe)
       frames_expected = {}
-      frames_expected[0] = len(self.payload) / self.p.autoFragmentSize
-      frames_expected[1] = 1 if len(self.payload) % self.p.autoFragmentSize > 0 else 0
+      payload = getattr(self, 'payload', b'')
+      frames_expected[0] = len(payload) / (self.p.autoFragmentSize or 1)
+      frames_expected[1] = 1 if len(payload) % (self.p.autoFragmentSize or 1) > 0 else 0
       frames_got = {}
-      frames_got[0] = self.p.txFrameStats[0]
-      frames_got[1] = self.p.txFrameStats[1]
+      for i in range(len(self.p.txFrameStats)):
+          frames_got[i] = self.p.txFrameStats[i]
       if frames_expected == frames_got:
          pass
       else:
diff --git a/autobahntestsuite/autobahntestsuite/case/case7_5_1.py b/autobahntestsuite/autobahntestsuite/case/case7_5_1.py
index b322e57..1d5c3d5 100644
--- a/autobahntestsuite/autobahntestsuite/case/case7_5_1.py
+++ b/autobahntestsuite/autobahntestsuite/case/case7_5_1.py
@@ -38,7 +38,8 @@ class Case7_5_1(Case):

       ## the close reason we sent was invalid UTF8, so we
       ## convert to HEX representation for later case reporting
-      self.p.localCloseReason = binascii.b2a_hex(self.p.localCloseReason)
+      if self.p.localCloseReason:
+          self.p.localCloseReason = binascii.b2a_hex(self.p.localCloseReason)

    def onOpen(self):
       self.payload = '\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\xed\xa0\x80\x65\x64\x69\x74\x65\x64'

from autobahn-testsuite.

remyroy avatar remyroy commented on May 17, 2024

I've had the same issue with testing AutobahnPython.

This issue seems to only happen when I ran the asyncio version (both Python 2 and Python 3) of AutobahnPython. My guess is that there is a bug in AutobahnPython with the asyncio version.

My workaround was to run the test suite using the twisted version of AutobahnPython.

from autobahn-testsuite.

oberstet avatar oberstet commented on May 17, 2024

@remyroy AutobahnTestsuite itself runs only on Twisted - this is reflected in the setup.py: https://github.com/tavendo/AutobahnTestSuite/blob/master/autobahntestsuite/setup.py#L87

from autobahn-testsuite.

remyroy avatar remyroy commented on May 17, 2024

@oberstet I was running AutobahnPython separately from AutobahnTestsuite. I was running https://github.com/tavendo/AutobahnPython/blob/master/examples/asyncio/wamp/basic/server.py as the server and wstest -m fuzzingclient with the following fuzzingclient.json file:

{
   "outdir": "./reports/servers",
   "servers": [
                  {
                     "agent": "AutobahnPython",
                     "url": "ws://127.0.0.1:9000"
                  }
              ],
   "cases": ["*"],
   "exclude-cases": [],
   "exclude-agent-cases": {}
}

from autobahn-testsuite.

remyroy avatar remyroy commented on May 17, 2024

My bad. I'm still getting the same problem with running https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/basic/basicrouter.py as the server to be tested by the test suite . So this is not an issue of asyncio vs twisted.

from autobahn-testsuite.

jscissr avatar jscissr commented on May 17, 2024

After using the workaround by tlynn, I still get some more errors:

Running test case ID 7.13.2 for agent AutobahnPython from peer 192.168.1.60:8080

Unhandled Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\s
electreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\t
cp.py", line 214, in doRead
    return self._dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\t
cp.py", line 220, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\twisted\w
ebsocket.py", line 98, in dataReceived
    self._dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1320, in _dataReceived
    self.consumeData()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1336, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1495, in processData
    return self.processDataHybi()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1809, in processDataHybi
    fr = self.onFrameEnd()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1910, in onFrameEnd
    self.processControlFrame()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1967, in processControlFrame
    if self.onCloseFrame(code, reasonRaw):
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 883, in onCloseFrame
    raise Exception("logic error")
exceptions.Exception: logic error

This happens multiple times, the TestSuite doesn't stop after these errors.
To fix this, I added some lines in Python 2.7.8\lib\site-packages\autobahn\websocket\protocol.py, at line 880:

            ## will set wasClean = False back again.
            pass
#added part
      elif self.state == WebSocketProtocol.STATE_CLOSED:
         ## The peer initiated a closing handshake but dropped immediately.
         self.wasClean = False
#end added part
      else:
         ## STATE_PROXY_CONNECTING, STATE_CONNECTING
         raise Exception("logic error")

Also, the fix by tlynn for 10.1.1 doesn't work for me, because self.p.txFrameStats is {0: 50, 1: 1, 8: 1}.
I changed it to: (file Python 2.7.8\Lib\site-packages\autobahntestsuite\case\case10_1_1.py)

      frames_expected[1] = 1 if len(payload) % (self.p.autoFragmentSize or 1) > 0 else 0
      frames_got = {}
      for i, v in self.p.txFrameStats.iteritems(): #modified
         if(i == 0 or i == 1): #modified
            frames_got[i] = v #modified
      if frames_expected == frames_got:
         pass

from autobahn-testsuite.

oberstet avatar oberstet commented on May 17, 2024

@ all interested: could you checkout if this commit works for you? at least it fixes the issue I could reproduce with the test case included in the commit ..

from autobahn-testsuite.

jscissr avatar jscissr commented on May 17, 2024

This one is still there:

Running test case ID 7.9.13 for agent AutobahnPython from peer 192.168.1.60:8080

Running test case ID 7.13.1 for agent AutobahnPython from peer 192.168.1.60:8080

Unhandled Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\s
electreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\t
cp.py", line 214, in doRead
    return self._dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\internet\t
cp.py", line 220, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\twisted\w
ebsocket.py", line 98, in dataReceived
    self._dataReceived(data)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1325, in _dataReceived
    self.consumeData()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1341, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1500, in processData
    return self.processDataHybi()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1814, in processDataHybi
    fr = self.onFrameEnd()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1915, in onFrameEnd
    self.processControlFrame()
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 1972, in processControlFrame
    if self.onCloseFrame(code, reasonRaw):
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\autobahn\websocket
\protocol.py", line 888, in onCloseFrame
    raise Exception("logic error")
exceptions.Exception: logic error
Running test case ID 7.13.2 for agent AutobahnPython from peer 192.168.1.60:8080

Unhandled Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\log
.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Program Files (x86)\Python 2.7.8\lib\site-packages\twisted\python\con
text.py", line 81, in callWithContext

See fix in my earlier comment.

Otherwise it works.

from autobahn-testsuite.

oberstet avatar oberstet commented on May 17, 2024

@J3S thanks! I've fixed that in AutobahnPython: crossbario/autobahn-python#283

from autobahn-testsuite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.