FastHttpUser error: only SOCK_STREAM type sockets are supported
See original GitHub issueThe code:
`import json from locust import SequentialTaskSet, task, constant from locust.contrib.fasthttp import FastHttpUser from locust import LoadTestShape
class Hong(SequentialTaskSet): @task def api_community_list(self): headers = {‘Content-Type’: ‘application/x-www-form-urlencoded’,‘tenantId’: ‘22’, “host”: “countyrmt-test-api.thecover.cn”} r_url = “/community/list” data = json.dumps({“page_size”: 10, “type”: 1}) requests_data = {“data”: data, ‘deviceid’: ‘1B722294-E6B7-4AB0-B60A-84AB9972BBCA-ODBD’, ‘token’: ‘e3620bae8bfb4d56902701466901ee93’, ‘optionName’: “test”} with self.client.post(r_url, data=requests_data, catch_response=True, name=r_url, headers=headers) as r: if r.content == b"": r.failure(“No data”) if r.status_code != 200: em = “request error --” + str(r.status_code) r.failure(em)
class LocustHljLocust(FastHttpUser): host = “http://123.4.28.255:80” wait_time = constant(0) tasks = {Hong: 1}`
An error occurred while passing headers in the request parameter:
[2020-12-22 17:26:08,722] thecovercs/ERROR/locust.user.task: only SOCK_STREAM type sockets are supported Traceback (most recent call last): File “d:\python\lib\site-packages\locust\user\task.py”, line 290, in run self.execute_next_task() File “d:\python\lib\site-packages\locust\user\task.py”, line 315, in execute_next_task self.execute_task(self._task_queue.pop(0)) File “d:\python\lib\site-packages\locust\user\task.py”, line 327, in execute_task task(self) File “D:\thecover_project\api_locust\locust_view\hongya\locust_hy.py”, line 27, in api_community_list with self.client.post(r_url, data=requests_data, catch_response=True, name=r_url, headers=headers) as r: File “d:\python\lib\site-packages\locust\contrib\fasthttp.py”, line 261, in post return self.request(“POST”, path, data=data, **kwargs) File “d:\python\lib\site-packages\locust\contrib\fasthttp.py”, line 189, in request response = self._send_request_safe_mode(method, url, payload=data, headers=headers, **kwargs) File “d:\python\lib\site-packages\locust\contrib\fasthttp.py”, line 109, in _send_request_safe_mode return self.client.urlopen(url, method=method, **kwargs) File “d:\python\lib\site-packages\geventhttpclient\useragent.py”, line 359, in urlopen last_error = self._handle_error(e, url=req.url) File “d:\python\lib\site-packages\geventhttpclient\useragent.py”, line 326, in _handle_error raise reraise(type(e), e, sys.exc_info()[2]) File “d:\python\lib\site-packages\six.py”, line 703, in reraise raise value File “d:\python\lib\site-packages\geventhttpclient\useragent.py”, line 354, in urlopen resp = self._urlopen(req) File “d:\python\lib\site-packages\locust\contrib\fasthttp.py”, line 402, in _urlopen resp = client.request( File “d:\python\lib\site-packages\geventhttpclient\client.py”, line 236, in request sock.sendfile(body) File “d:\python\lib\site-packages\gevent_socket3.py”, line 684, in sendfile return self._sendfile_use_send(file, offset, count) File “d:\python\lib\site-packages\gevent_socket3.py”, line 614, in _sendfile_use_send self._check_sendfile_params(file, offset, count) File “d:\python\lib\site-packages\gevent_socket3.py”, line 653, in _check_sendfile_params raise ValueError(“only SOCK_STREAM type sockets are supported”) ValueError: only SOCK_STREAM type sockets are supported
The same code, using HttpUser does not have this problem。
Environment
- OS: windows
- Python version: Python 3.8.3
- Locust version:locust 1.3.2
- Locust command line that you ran:
- Locust file contents (anonymized if necessary):
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
There’s nothing special on the server. er, I’ll use HttpUser or use ‘Get’ method first~ Anyway, thank you all very much!
Closing this (feel free to reopen if there is a clear repro case with a publically available server)