错误:写入 EPROTO 4455222784:错误:1408F10B:SSL 例程:ssl3_get_record:错误的版本号:../deps/openssl/openssl/ssl/record

Posted

技术标签:

【中文标题】错误:写入 EPROTO 4455222784:错误:1408F10B:SSL 例程:ssl3_get_record:错误的版本号:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:【英文标题】:Error: write EPROTO 4455222784:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332: 【发布时间】:2021-08-04 08:09:00 【问题描述】:

我有一个使用 ws nodejs 库在后端运行的 websocket 服务器。每当我尝试从客户端连接到它时,我都会收到此错误。

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: write EPROTO 4455222784:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)
Emitted 'error' event on WebSocket instance at:
    at ClientRequest.<anonymous> (/Volumes/lilac/Projects/Projects/5. Fireplace/fireplace/node_modules/ws/lib/websocket.js:718:15)
    at ClientRequest.emit (events.js:400:28)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) 
  errno: -100,
  code: 'EPROTO',
  syscall: 'write'

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fireplace@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fireplace@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/debabrata/.npm/_logs/2021-08-04T07_56_05_447Z-debug.log

这是在服务器上运行的代码:

import  createServer  from "http"                                   
import  WebSocketServer  from "ws"                                  

const server = createServer()                                         
const wss = new WebSocketServer( server )                           
                                                  
                                                                      
server.listen("8080", () =>                                          
    console.log("Server listening on port 8080")                      
)                                                                    
                                                                      
wss.on("connection", (ws, req) =>                                    
    ws.on("open", () => console.log("connection open"))               
    ws.on("close", () => console.log("connection closed"))                                                                       
)

客户端代码(Next.js)

import WebSocket from 'isomorphic-ws'                                   
import useEffect from 'react'                                         
                                                                         
const ws = new WebSocket("wss://localhost:8080/")                       
                                                                        
const Page = () =>                                                    
                                                                        
    useEffect(() =>                                                    
        ws.onopen = () =>                                              
            console.log("connection open")                              
                                                                       
    )                                                                  
                                                                       
    return (                                                            
        <div>                                                           
        </div>                                                          
    )                                                                   
                                                                       
export default Page

我还应该提到,在构建它时我必须更新 npm 和节点版本。这会导致问题吗?我该如何解决这个问题?

【问题讨论】:

【参考方案1】:

我又回头看了看。如果我连接到ws://localhost:808,它就可以工作

【讨论】:

以上是关于错误:写入 EPROTO 4455222784:错误:1408F10B:SSL 例程:ssl3_get_record:错误的版本号:../deps/openssl/openssl/ssl/record的主要内容,如果未能解决你的问题,请参考以下文章

npm install failed EPROTO 获取请求失败

python pip安装库时报错?

C#读取Excle文件时报错,怎么处理?

Cloudkit 公共数据库错误:“不允许写入操作”

R studio错误:无法保存也无法写入csv

mysql 案例 ~ 程序端报错案例