You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用OpenAI Whisper模型时出现ECONNRESET错误的原因是什么?

问题描述

我开发了一个基于HTML和OpenAI Whisper模型的应用,原本运行正常,但现在从OpenAI服务器获取转录文本时持续报错。本地在localhost:8080启动网页后,无法正常显示转录结果,报错信息如下:

Received file: uploads/input.wav
Error during transcription: APIConnectionError: Connection error.
at OpenAI.makeRequest (/Users/vivannkhanna/voice-recorder-app/node_modules/openai/core.js:304:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/vivannkhanna/voice-recorder-app/server.js:42:37 {
status: undefined,
headers: undefined,
request_id: undefined,
error: undefined,
code: undefined,
param: undefined,
type: undefined,
cause: FetchError: request to https://api.openai.com/v1/audio/transcriptions failed, reason: read ECONNRESET
at ClientRequest.<anonymous> (/Users/vivannkhanna/voice-recorder-app/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:519:28)
at TLSSocket.socketErrorListener (node:_http_client:500:9)
at TLSSocket.emit (node:events:531:35)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'ECONNRESET',
code: 'ECONNRESET'

排查与解决方法

  • 检查网络连接稳定性:ECONNRESET通常是连接中途被重置,先在终端执行curl https://api.openai.com/v1/models测试能否正常访问API域名。如果请求失败,检查本地网络、防火墙设置,确保没有拦截OpenAI的API请求。
  • 验证API密钥有效性:确认服务器代码中的OpenAI API密钥是否正确、未过期,也可以在OpenAI后台查看密钥的权限状态,必要时替换新密钥测试。
  • 调整请求超时参数:如果是大音频文件导致请求超时,初始化OpenAI客户端时设置更长的超时时间:
    const openai = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY,
      timeout: 60000 // 设置为60秒
    });
    
  • 检查音频文件完整性:确认上传的input.wav文件未损坏,格式符合Whisper要求(支持wav、mp3等格式,建议采样率16kHz),可以重新录制或上传正常音频测试。
  • 升级OpenAI SDK版本:执行npm update openai将SDK升级到最新版本,避免旧版本的请求逻辑bug导致连接问题。
  • 排查代理/VPN干扰:如果使用了代理或VPN,尝试关闭后再测试,部分代理会中断HTTPS连接引发ECONNRESET错误。

内容的提问来源于stack exchange,提问作者vivann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 19:14:51