• 代理问题:python & jmeter


    最近遇到下面几个问题:(亲测有用)

    1. python写接口测试的时候,在mac上面执行脚本的时候一直报错

    self = <ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, block = False
    
        @_sslcopydoc
        def do_handshake(self, block=False):
            self._check_connected()
            timeout = self.gettimeout()
            try:
                if timeout == 0.0 and block:
                    self.settimeout(None)
    >           self._sslobj.do_handshake()
    E           ConnectionResetError: [Errno 54] Connection reset by peer

    2. jmeter运行脚本的时候一直报错

    javax.net.ssl.SSLProtocolException: Connection reset
        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
        at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConne
    .....

    可以看到都是和代理相关的问题

    项目背景:都需要使用shadowsocksFQ

    上面的报错就是因为终端(python, jmeter)走不了shadowsocks

    解决方法:

    1. python接口脚本中添加代码(还可以使用proxychains https://www.jianshu.com/p/5115ea84bb90)

    proxy_addr = {
                'https': 'https://127.0.0.1:1080',  # 本地shadowsocks代理端口
                'http': 'http://127.0.0.1:1080'
            }
    r.get(url, params=data["params"], headers=self.headers, verify=False, proxies=proxy_addr)

    2. jmeter在http request上配置代理(可以配在http requests default上面)

  • 相关阅读:
    树莓派4B 多屏 QT程序窗口全屏 QScreen 只能获取1个屏幕
    树莓派4B 微雪7寸触摸屏 双屏 触摸屏校正
    虚拟机 ubuntu18 树莓派4 QT5.14.2 交叉编译
    Qt 指定 so库 运行时路径
    building qtqml requires python
    python django 测试报告 发送邮件
    jmeter XPath Extractor
    python+unittest+HTMLTestRunner生成测试报告
    Genymotion、 uiautomatorviewer、 appium报错
    jmeter forEach控制器
  • 原文地址:https://www.cnblogs.com/lj8023wh/p/11191252.html
Copyright © 2020-2023  润新知