Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

vue websocket向后端发送blob为空

我写的是实时语音转写
这是socket配置

socket(){
    this.ws = new WebSocket(this.path)
    this.ws.binaryType = 'blob';
    this.ws.onopen = function(){
        console.log('ws已连接')
    }
    this.ws.onmessage = function(data){
        // console.log(data)
    }
    this.ws.onclose = function(){
        console.log('closed')
    }
    this.ws.onerror = function(err){
        console.log('error:'+err)
    }
},

这个是blob在浏览器打印是有长度大小的

console.log(new Blob([buf4]))

这个是浏览器打印的blob
image
这是发送blob

that.ws.send(new Blob([buf4]))

发送的为空
image

buf4是二进制数据
求大神帮忙看看是哪里的原因


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

image.png

只是看不到,其实发成功了。服务端收到了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...