当我建立连接时,网络套接字立即关闭,代码为 1000。有人能告诉我为什么会发生这种情况吗?
这是我的简单代码:
let ws = new WebSocket("wss://myhost/my-path?param1=value1¶m2=value2")
ws.onopen = () => console.log('OPEN')
ws.onclose = (e) => console.log('CLOSE: code: ' + e.code)
ws.onmessage = (e) => console.log('MESSAGE: ', e.data)
ws.onerror = () => console.log('ERROR')
// The result is:
// OPEN
// CLOSE: code: 1000
Run Code Online (Sandbox Code Playgroud)
反应原生信息
$ react-native info
Environment:
OS: macOS High Sierra 10.13.5
Node: 8.9.4
Yarn: 0.21.3
npm: 5.7.1
Watchman: 4.7.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: 3.1 AI-173.4720617
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1 …Run Code Online (Sandbox Code Playgroud) 大家好,我尝试在我的 reactJS 应用程序中实现getUserMedia来录制音频。
我努力将我的 mediaRecorder this.state 对象链接到状态更改,并使媒体设备 API 获得我提供应用程序所需的功能。
当我在视图上单击“开始记录”时,我的控制台返回给我:
TypeError: this.state.mediaRecorder.start is not a function
48 | startRecord() {
49 |
50 |
51 | this.setState({mediaRecorder:this.state.mediaRecorder.start()});
52 | alert("start record function started =, mediaRecorder state : " + this.state.mediaRecorder.state)
53 | console.log(this.state.mediaRecorder.state); // > recording
54 | console.log("recorder started"); View compiled
Run Code Online (Sandbox Code Playgroud)
这是我的 app.js :
import React from "react";
// import "./install.js" ;
import "./mediaDevices-getUserMedia-polyfill.js";
class RecorderAPI extends React.Component {
constructor(props) {
super(props);
this.handleDelete = this.handleDelete.bind(this);
this.startRecord = …Run Code Online (Sandbox Code Playgroud)