12

I have written Robot Framework test scripts in .tsv format to test web-services/APIs. Everything was working fine until today (probably because of the new updates of Robot Framework) when I started to get the following error:

SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

This error keeps popping up for the following code in a test script:

${headers}=  Create Dictionary Content-Type application/json  Accept application/json
RequestsKeywords.Get Request httpbin ${url} headers=${headers} //ERROR SHOWS FOR THIS STATEMENT

I did get a detailed traceback for this error which is as follows:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/RequestsLibrary/RequestsKeywords.py", line 298, in get_request
    session, uri, params, headers, redir, timeout)
  File "/Library/Python/2.7/site-packages/RequestsLibrary/RequestsKeywords.py", line 801, in _get_request
    cookies=self.cookies)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)

My system configuration:

Mac OS X (10.11.3)
Python (2.7.10)
openssl (1.0.2f)
requests (2.9.1)
robotframework (3.0)
robotframework-httplibrary (0.4.2)
robotframework-requests (0.4.4)
robotframework-ride (1.5.2.1)
robotframework-sshlibrary (2.1.2)
pyOpenSSL (0.15.1)

How do I resolve this issue?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
giri-sh
  • 6,934
  • 2
  • 25
  • 50
  • When you say "probably because of the new updates", what updates are you talking about? To your server? To robot? To the requests module? To python? To OSX? – Bryan Oakley Mar 01 '16 at 15:41
  • I updated robot framework libraries (all of them) mentioned in system config in question. Thanks – giri-sh Mar 01 '16 at 15:43
  • ***`SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)`*** is not telling us much. It looks like it not an accurate error number (to me). Can you provide the error returned from OpenSSL's ***[`ERR_get_error`](http://www.openssl.org/docs/manmaster/crypto/ERR_get_error.html)*** or ***[`SSL_get_error`](http://www.openssl.org/docs/manmaster/ssl/SSL_get_error.html)***? – jww Mar 01 '16 at 17:32
  • @jww how do i get that error? I am running robot framework automation scripts and it only shows the traceback error mentioned in the question. – giri-sh Mar 02 '16 at 10:14
  • `${headers}= Create Dictionary Content-Type application/json Accept application/json` is wrong, should be `&{headers}= Create Dictionary Content-Type=application/json Accept=application/json` – Nizam Mohamed Mar 10 '16 at 11:04
  • `url` argument of `Get Request` must be relative like `/path`. – Nizam Mohamed Mar 10 '16 at 11:09
  • Yes url argument is indeed a relative path. The same script works in my colleague's system. So i think its a config issue, but dont know how to figure that out as OpenSSL doesn't provide enough information on the error. Thanks – giri-sh Mar 10 '16 at 11:12
  • did you notice my previous comment? `Create Dictionary` is wrong. Check [here](https://github.com/bulkan/robotframework-requests/blob/master/tests/testcase.txt). FYI, use `@user` in the comment to let the user know you've commented back. – Nizam Mohamed Mar 10 '16 at 18:10
  • @NizamMohamed i did notice your previous comment. Can you explain why `Create Dictionary` is wrong? Also i did mention that the same script works in other machine, so how can it be wrong? Robot framework has many formats and one of them is `.tsv` which is a keyword driven framework and so there is no need to add `=` in between keywords on right hand side. Thanks – giri-sh Mar 11 '16 at 07:24
  • I didn't know much about robotframework. I just went thorugh the [file](https://github.com/bulkan/robotframework-requests/blob/master/tests/testcase.txt). In every `Create Dictionary`occurrence in the file, dictionary name is like `&{name}`, not like `${name}` and arguments are space separated. – Nizam Mohamed Mar 11 '16 at 09:54
  • @NizamMohamed yeah there are many formats in robot framework. So they vary with each other. However, i am not sure what configuration issue is creating this issue. Thanks :) – giri-sh Mar 11 '16 at 09:59

2 Answers2

3

You're all up to date, so there are two possibilities:

  • The handshake isn't going smoothly because of a break in the trust chain. Start from the bottom and work up. Are you testing this on a local area network? Is the certificate up to date? Can you access the site from your location and others without an error? SSL labs showing anything up? What about firewall rules?
  • There's a bug in the recent update. OpenSSL reports in my experience are caused by connection issues rather than obscure software problems - this is the less likely of the two.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
L Martin
  • 1,180
  • 8
  • 18
  • handshake is working as it should be because my colleagues can perform the same operation and it works for them. So i probably guess its because of some configuration issue that's creating this problem. – giri-sh Mar 09 '16 at 07:55
  • Do check your firewall rules if it's specific to yourself! This has caught me out before :( – L Martin Mar 09 '16 at 15:56
  • I did check my firewall rules and it seems to be fine. I also made sure that python had the rights in firewall by enabling it in recovery mode in mac. Thanks. – giri-sh Mar 11 '16 at 07:26
  • Well this is just headache inducing! It's almost certainly a connection issue - test the library with a hello world is all I can suggest. – L Martin Mar 14 '16 at 09:41
1

Try installing requests[security] instead of requests. It uses PyOpenSSL, which is better than OpenSSL: pip install requests[security] vs pip install requests: Difference

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fodma1
  • 3,485
  • 1
  • 29
  • 49
  • I ran `pip install -U requests[security]` command, and i got requirement satisfied result in command line. So i think its already installed with requests itself, though i am not sure. But i did install `PyOpenSSL`, `ndg-httpsclient` and `pyasn1` and script still fails. Thanks – giri-sh Mar 11 '16 at 07:33
  • @fodma1 "On Python 3.4+ and Python 2.7.9+ it's not better anymore", see [here](https://github.com/kennethreitz/requests/pull/2195#issuecomment-53934322) – Nizam Mohamed Mar 11 '16 at 10:11