WebSocket 链接的 User-Agent 异常
发布于 4 年前 作者 fjin 7579 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

我们有API会把完整的HTTP请求报文返回给客户端,客户端再通过云函数,把 HTTP报文 加上openid 返回给后台,来确定不是爬虫的行为

目前收到异常的 HTTP 报文:

GET /xxx HTTP/1.1
Host: xxx
Connection: upgrade
Sec-Websocket-Key: zm7HEXzq+AbnYMK\/Bdvt2g==
Sec-Websocket-Version: 13
Upgrade: websocket
User-Agent: WebSocket++/0.8.1

报文里的 User-Agent 不是小程序的,也没有客户端设置的认证信息

客户端具体信息:

{
    "SDKVersion": "2.6.6",
    "albumAuthorized": true,
    "batteryLevel": 54,
    "bluetoothEnabled": false,
    "brand": "iPhone",
    "cameraAuthorized": true,
    "deviceOrientation": "portrait",
    "fontSizeSetting": 17,
    "language": "zh_CN",
    "locationAuthorized": true,
    "locationEnabled": true,
    "microphoneAuthorized": true,
    "model": "iPhone 7<iPhone9,1>",
    "notificationAlertAuthorized": true,
    "notificationAuthorized": true,
    "notificationBadgeAuthorized": true,
    "notificationSoundAuthorized": true,
    "pixelRatio": 2,
    "platform": "ios",
    "screenHeight": 667,
    "screenWidth": 375,
    "statusBarHeight": 20,
    "system": "iOS 12.1",
    "version": "7.0.3",
    "wifiEnabled": true,
    "windowHeight": 603,
    "windowWidth": 375
}
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo
2 回复

我们近期在灰度替换 WebSocket 的底层实现,会出现这个不同的 UA。这个暂时只能你来兼容一下了。

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

回到顶部