javascript - node.js - StripeConnectionError
问题描述
最近在尝试通过 Node.js 查找 Stripe 客户或帐户时收到以下错误。
我正在使用stripe.accounts.retrieve
和stripe.subscriptions.retrieve
。
{
"type": "StripeConnectionError",
"stack": "Error: An error occurred with our connection to Stripe\n at Constructor._Error (/var/www/w3bbi/node_modules/stripe/lib/Error.js:12:17)\n at Constructor (/var/www/w3bbi/node_modules/stripe/lib/utils.js:124:13)\n at Constructor (/var/www/w3bbi/node_modules/stripe/lib/utils.js:124:13)\n at ClientRequest. (/var/www/w3bbi/node_modules/stripe/lib/StripeResource.js:206:9)\n at emitOne (events.js:96:13)\n at ClientRequest.emit (events.js:189:7)\n at TLSSocket.socketErrorListener (_http_client.js:358:9)\n at emitOne (events.js:96:13)\n at TLSSocket.emit (events.js:189:7)\n at emitErrorNT (net.js:1280:8)\n at _combinedTickCallback (internal/process/next_tick.js:74:11)\n at process._tickDomainCallback (internal/process/next_tick.js:122:9)",
"message": "An error occurred with our connection to Stripe",
"detail": {
"code": "ECONNRESET"
},
"raw": {
"message": "An error occurred with our connection to Stripe",
"detail": {
"code": "ECONNRESET"
}
}
}
关于可能导致这种情况的任何想法?我刚刚在我的 Ubuntu 服务器上升级了我的 OpenSSL 包,但这似乎并没有解决问题。
此错误似乎并非每次都会发生,而是每隔几次尝试都会发生。大多数情况下,我成功检索了 Stripe 订阅或帐户,但每隔一段时间,我就会收到此错误。
我的 node.js 代码也很简单——
stripe.subscriptions.retrieve(STRIPE_SUB_ID, function(err, subscription) {
//want to do something with subscription here, but i get err instead (only ever so often)
})
太感谢了!!
解决方案
您可以尝试curl
使用条带 API 吗?
你可以
- 登录到您的条带帐户
- 转到https://stripe.com/docs/api/curl#retrieve_customer
- 复制粘贴示例中的请求。它会像
curl https://api.stripe.com/v1/customers/cus_DbAXqdmjzVPz2I \ -u <your private api key>
- 在此处粘贴您的回复
让我知道它是否正常工作,如果可以的话,您还可以分享您的节点 js 代码(省略您的密钥)。
推荐阅读
- css - 对同一个 React 应用使用两个 style.css
- php - Angular 服务调用丢失发布变量
- c++ - 转换为指向私有类函数的指针
- c++ - 如何将 cdparanoia 读取的 CD 音频数据交给 ALSA 播放器?
- r - 如何将列表中的所有数据框合并到单个数据框?
- windows - AutoHotKey Hotstring 不会在 Windows 上的 gvim 或 WSL Ubuntu 中的 vim 中触发
- powershell - 复制项 cmdlet 仅在目标文件夹存在时才能正常工作
- docker - Docker compose 抛出 - adduser: group 'www-data' in use
- java - 即使文件存在于机器中,也无法使用 Android 访问本地机器上的文件
- powerbi - 对列的 MAX 值求和