问题已解决! 确认问题出在socket地址传参上面,一旦带有中文字符需要encodeURI
安卓真机调试建立socket连接失败,直接进入onSocketError?模拟器和IOS真机均正常,android真机 打开调试,进入onSocketError,错误code1004,错误message : invalid HTTP status[图片] [代码]connectSocketFun:[代码][代码]function[代码][代码]() {[代码] [代码] [代码][代码]console.log([代码][代码]"开始连接设备"[代码][代码])[代码] [代码] [代码][代码]let wxs =[代码][代码]this[代码] [代码] [代码][代码]//建立连接[代码] [代码] [代码][代码]wx.connectSocket({[代码] [代码] [代码][代码]url: socketUrl +[代码][代码]'/websocket/'[代码] [代码]+ wxs.data.noWashCar.deviceNumber +[代码][代码]'/'[代码] [代码]+ wxs.data.noWashCar.numberPlate +[代码][代码]'/'[代码] [代码]+ wxs.data.noWashCar.orderId[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]let socketOpen =[代码][代码]false[代码] [代码] [代码][代码]const socketMsgQueue = [][代码] [代码] [代码][代码]//连接成功[代码] [代码] [代码][代码]wx.onSocketOpen([代码][代码]function[代码][代码](res) {[代码] [代码] [代码][代码]wx.showLoading({[代码] [代码] [代码][代码]title:[代码][代码]'正在同步位置'[代码][代码],[代码] [代码] [代码][代码]mask:[代码][代码]true[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]socketOpen =[代码][代码]true[代码] [代码] [代码][代码]console.log([代码][代码]"res"[代码][代码])[代码] [代码] [代码] [代码] [代码][代码]})[代码] [代码] [代码] [代码] [代码][代码]//接收数据[代码] [代码] [代码][代码]wx.onSocketMessage([代码][代码]function[代码][代码](data) {[代码] [代码] [代码][代码]console.log([代码][代码]"data"[代码][代码], data)[代码] [代码] [代码][代码]// if (data.data == "SUCCESS") {[代码] [代码] [代码] [代码] [代码][代码]console.log([代码][代码]"接收的数据"[代码][代码], data);[代码] [代码] [代码][代码]if[代码] [代码](data.data !=[代码][代码]"FAIL"[代码][代码]) {[代码] [代码] [代码][代码]wxs.setData({[代码] [代码] [代码][代码]deadShipCondition: JSON.parse(data.data).Data,[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]console.log([代码][代码]"deadShipCondition"[代码][代码], wxs.data.deadShipCondition)[代码] [代码] [代码][代码]let mqtt_connect =[代码][代码]''[代码] [代码] [代码][代码]let forward =[代码][代码]''[代码] [代码] [代码][代码]let backward =[代码][代码]''[代码] [代码] [代码][代码]let finished =[代码][代码]''[代码] [代码] [代码][代码]let running =[代码][代码]''[代码] [代码] [代码][代码]let text =[代码][代码]''[代码] [代码] [代码] [代码] [代码][代码]let isSegment =[代码][代码]''[代码] [代码] [代码][代码]for[代码] [代码](let iin wxs.data.deadShipCondition) {[代码] [代码] [代码][代码]//停车到位[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name ==[代码][代码]'VEHICLE_POSITIONED'[代码][代码]) {[代码] [代码] [代码][代码]mqtt_connect = wxs.data.deadShipCondition[i][代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]//指示灯提示向后(车辆位置靠前)[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name ==[代码][代码]'BACKWARD'[代码][代码]) {[代码] [代码] [代码][代码]forward = wxs.data.deadShipCondition[i][代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]//指示灯提示向前(车辆位置靠后)[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name ==[代码][代码]'FORWARD'[代码][代码]) {[代码] [代码] [代码][代码]backward = wxs.data.deadShipCondition[i][代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]//洗车中[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name ==[代码][代码]'RUNNING'[代码][代码]) {[代码] [代码] [代码][代码]running = wxs.data.deadShipCondition[i][代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]//清洗结束[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name ==[代码][代码]'FINISHED'[代码][代码]) {[代码] [代码] [代码][代码]finished = wxs.data.deadShipCondition[i][代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]if[代码] [代码](backward.value == 1) {[代码] [代码] [代码][代码]text =[代码][代码]"车辆向前"[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]if[代码] [代码](forward.value == 1) {[代码] [代码] [代码][代码]text =[代码][代码]"车辆向后"[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]if[代码] [代码](mqtt_connect.value == 1) {[代码] [代码] [代码][代码]text =[代码][代码]"停车到位"[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]if[代码] [代码](running.value == 1) {[代码] [代码] [代码][代码]text =[代码][代码]"洗车中"[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]if[代码] [代码](finished.value == 1) {[代码] [代码] [代码][代码]text =[代码][代码]"清洗结束"[代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]let nvabarDataTitle =[代码][代码]'nvabarData.title'[代码] [代码] [代码] [代码] [代码][代码]wxs.setData({[代码] [代码] [代码][代码][nvabarDataTitle]: text,[代码] [代码] [代码][代码]//停车到位[代码] [代码] [代码][代码]mqtt_connect: mqtt_connect,[代码] [代码] [代码][代码]//交通灯指示向前[代码] [代码] [代码][代码]FORWARD: forward,[代码] [代码] [代码][代码]//交通指示灯向后[代码] [代码] [代码][代码]BACKWARD: backward,[代码] [代码] [代码][代码]//洗车完成[代码] [代码] [代码][代码]FINISHED: finished,[代码] [代码] [代码][代码]//洗车进行中[代码] [代码] [代码][代码]RUNNING: running,[代码] [代码] [代码][代码]// isSegment: isSegment[代码] [代码] [代码][代码]// noCarInPlace:1[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]if[代码] [代码](wxs.data.FINISHED.value == 1) {[代码] [代码] [代码][代码]wx.closeSocket()[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]wx.hideLoading()[代码] [代码] [代码][代码]}[代码][代码]else[代码] [代码]{[代码] [代码] [代码][代码]wx.hideLoading()[代码] [代码] [代码][代码]wx.showToast({[代码] [代码] [代码][代码]title:[代码][代码]'暂无车辆到位'[代码][代码],[代码] [代码] [代码][代码]icon:[代码][代码]'none'[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]wxs.setData({[代码] [代码] [代码][代码]noCarInPlace: 0[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码] [代码] [代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]wx.onSocketError((errMsg) => {[代码] [代码] [代码][代码]console.log([代码][代码]"socket连接失败"[代码][代码], errMsg)[代码] [代码] [代码][代码]})[代码] [代码] [代码] [代码]},[代码]日志已上传,微信号"and-you--",时间2019年11月25日14时43分
2019-11-25问题已解决! 确认问题出在socket地址传参上面,一旦带有中文字符需要encodeURI
android真机无法建立socket连接,直接进入onSocketError?模拟器和IOS真机均正常,android真机 打开调试,进入onSocketError,错误code1004 [图片] [代码]connectSocketFun: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]console.log([代码][代码]"开始连接设备"[代码][代码])[代码][代码] [代码][代码]let wxs = [代码][代码]this[代码][代码] [代码][代码]//建立连接[代码][代码] [代码][代码]wx.connectSocket({[代码][代码] [代码][代码]url: socketUrl + [代码][代码]'/websocket/'[代码] [代码]+ wxs.data.noWashCar.deviceNumber + [代码][代码]'/'[代码] [代码]+ wxs.data.noWashCar.numberPlate + [代码][代码]'/'[代码] [代码]+ wxs.data.noWashCar.orderId[代码][代码] [代码][代码]})[代码][代码] [代码][代码]let socketOpen = [代码][代码]false[代码][代码] [代码][代码]const socketMsgQueue = [][代码][代码] [代码][代码]//连接成功[代码][代码] [代码][代码]wx.onSocketOpen([代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]wx.showLoading({[代码][代码] [代码][代码]title: [代码][代码]'正在同步位置'[代码][代码],[代码][代码] [代码][代码]mask: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]socketOpen = [代码][代码]true[代码][代码] [代码][代码]console.log([代码][代码]"res"[代码][代码])[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]//接收数据[代码][代码] [代码][代码]wx.onSocketMessage([代码][代码]function[代码][代码](data) {[代码][代码] [代码][代码]console.log([代码][代码]"data"[代码][代码], data)[代码][代码] [代码][代码]// if (data.data == "SUCCESS") {[代码] [代码] [代码][代码]console.log([代码][代码]"接收的数据"[代码][代码], data);[代码][代码] [代码][代码]if[代码] [代码](data.data != [代码][代码]"FAIL"[代码][代码]) {[代码][代码] [代码][代码]wxs.setData({[代码][代码] [代码][代码]deadShipCondition: JSON.parse(data.data).Data,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]"deadShipCondition"[代码][代码], wxs.data.deadShipCondition)[代码][代码] [代码][代码]let mqtt_connect = [代码][代码]''[代码][代码] [代码][代码]let forward = [代码][代码]''[代码][代码] [代码][代码]let backward = [代码][代码]''[代码][代码] [代码][代码]let finished = [代码][代码]''[代码][代码] [代码][代码]let running = [代码][代码]''[代码][代码] [代码][代码]let text = [代码][代码]''[代码] [代码] [代码][代码]let isSegment = [代码][代码]''[代码][代码] [代码][代码]for[代码] [代码](let i [代码][代码]in[代码] [代码]wxs.data.deadShipCondition) {[代码][代码] [代码][代码]//停车到位[代码][代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name == [代码][代码]'VEHICLE_POSITIONED'[代码][代码]) {[代码][代码] [代码][代码]mqtt_connect = wxs.data.deadShipCondition[i][代码][代码] [代码][代码]}[代码] [代码] [代码][代码]//指示灯提示向后(车辆位置靠前)[代码][代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name == [代码][代码]'BACKWARD'[代码][代码]) {[代码][代码] [代码][代码]forward = wxs.data.deadShipCondition[i][代码][代码] [代码][代码]}[代码] [代码] [代码][代码]//指示灯提示向前(车辆位置靠后)[代码][代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name == [代码][代码]'FORWARD'[代码][代码]) {[代码][代码] [代码][代码]backward = wxs.data.deadShipCondition[i][代码][代码] [代码][代码]}[代码][代码] [代码][代码]//洗车中[代码][代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name == [代码][代码]'RUNNING'[代码][代码]) {[代码][代码] [代码][代码]running = wxs.data.deadShipCondition[i][代码][代码] [代码][代码]}[代码] [代码] [代码][代码]//清洗结束[代码][代码] [代码][代码]if[代码] [代码](wxs.data.deadShipCondition[i].name == [代码][代码]'FINISHED'[代码][代码]) {[代码][代码] [代码][代码]finished = wxs.data.deadShipCondition[i][代码][代码] [代码][代码]}[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]if[代码] [代码](backward.value == 1) {[代码][代码] [代码][代码]text = [代码][代码]"车辆向前"[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](forward.value == 1) {[代码][代码] [代码][代码]text = [代码][代码]"车辆向后"[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](mqtt_connect.value == 1) {[代码][代码] [代码][代码]text = [代码][代码]"停车到位"[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](running.value == 1) {[代码][代码] [代码][代码]text = [代码][代码]"洗车中"[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](finished.value == 1) {[代码][代码] [代码][代码]text = [代码][代码]"清洗结束"[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]let nvabarDataTitle = [代码][代码]'nvabarData.title'[代码] [代码] [代码][代码]wxs.setData({[代码][代码] [代码][代码][nvabarDataTitle]: text,[代码][代码] [代码][代码]//停车到位[代码][代码] [代码][代码]mqtt_connect: mqtt_connect,[代码][代码] [代码][代码]//交通灯指示向前[代码][代码] [代码][代码]FORWARD: forward,[代码][代码] [代码][代码]//交通指示灯向后[代码][代码] [代码][代码]BACKWARD: backward,[代码][代码] [代码][代码]//洗车完成[代码][代码] [代码][代码]FINISHED: finished,[代码][代码] [代码][代码]//洗车进行中[代码][代码] [代码][代码]RUNNING: running,[代码][代码] [代码][代码]// isSegment: isSegment[代码][代码] [代码][代码]// noCarInPlace:1[代码][代码] [代码][代码]})[代码][代码] [代码][代码]if[代码] [代码](wxs.data.FINISHED.value == 1) {[代码][代码] [代码][代码]wx.closeSocket()[代码][代码] [代码][代码]}[代码][代码] [代码][代码]wx.hideLoading()[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码] [代码] [代码][代码]wx.hideLoading()[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'暂无车辆到位'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]wxs.setData({[代码][代码] [代码][代码]noCarInPlace: 0[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]})[代码][代码] [代码][代码]wx.onSocketError((errMsg) => {[代码][代码] [代码][代码]console.log([代码][代码]"socket连接失败"[代码][代码], errMsg)[代码][代码] [代码][代码]})[代码] [代码]},[代码][图片]
2019-11-25