websocket 踩坑记录


ssh execute command error: can't connect str to butes
ssh 发送下一次指令回传的是上一次指令的结果
ssh 始终停留在 root 目录内
ssh 能正确回传了但回传值有附加的字符<-[0m <-[01;34m**
websocket 没有错误断开但只发送不回传
更新了代码刷新页面之后websocket close

此文章后续还会继续补充,未完待续。。。



ssh execute command error: can't connect str to butes

channel.send(msg + b'\n')
out = channel.recv(1024)





ssh 发送下一次指令回传的是上一次指令的结果


错误code

channel.send(msg + b'\n')
out = channel.recv(1024)

uwsgi.websocket_send(out)

解决code

channel.send(msg + b'\n')
time.sleep(0.3)             # 等待一段时间
out = channel.recv(1024)




ssh 始终停留在 root 目录内


错误code

channel.send(msg + b'\n')
out = channel.recv(1024)

uwsgi.websocket_send(out)

解决code

channel.send(msg + b'\n')
time.sleep(0.3)             # 等待一段时间
out = channel.recv(1024)





ssh 能正确回传了但回传值有附加的字符<-[0m <-[01;34m

现象:

[root@localhost ~]#ls
anaconda-ks,cfg  <-[0m<-[01;34mdino<-[0m  <-[01;34mgrub<-[0m
<-[01;34mDecktop<-[0m  <-[01;34mDocuments<-[0m

解决:

这是 linux 环境下自带的字符串颜色识别字符
用前端插件 term.js 识别颜色字符





websocket 没有错误断开但只发送不回传


console:

sending.....




更新了代码刷新页面之后 websocket close


console:

connect! websocket open
Connection is closed...

解决:
更新代码之后要reload, 这时 websocket 会被关掉 刷新时是还没处于正在关闭状态 再刷一次就好了

posted @ 2019-02-27 14:16  Janey91  阅读(1459)  评论(0编辑  收藏  举报