Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker服务启动一段时间后就失效 #76

Closed
shog86 opened this issue Jun 11, 2024 · 16 comments
Closed

docker服务启动一段时间后就失效 #76

shog86 opened this issue Jun 11, 2024 · 16 comments

Comments

@shog86
Copy link
Contributor

shog86 commented Jun 11, 2024

报错信息(不停地跳新的,截了一中间一断)

❌ Network request failed: UNKNOWN CODE UNKNOWN ERROR <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1></body></html>
getConversations failed {
  error: AxiosError: Request failed with status code 401
      at settle (/app/node_modules/.pnpm/axios@1.6.8/node_modules/axios/dist/node/axios.cjs:1966:12)
      at IncomingMessage.handleStreamEnd (/app/node_modules/.pnpm/axios@1.6.8/node_modules/axios/dist/node/axios.cjs:3065:11)
      at IncomingMessage.emit (node:events:531:35)
      at endReadableNT (node:internal/streams/readable:1696:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    code: 'ERR_BAD_REQUEST',
    config: {
      transitional: [Object],
      adapter: [Array],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 10000,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: [Object],
      validateStatus: [Function: validateStatus],
      headers: [Object [AxiosHeaders]],
      proxy: false,
      decompress: true,
      cookies: [Object],
      method: 'get',
      url: 'https://userprofile.mina.mi.com/device_profile/v2/conversation?limit=2&requestId=750c1e68829f&source=dialogu&hardware=LX01',
      data: undefined
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: true,
      socket: [TLSSocket],
      _header: 'GET /device_profile/v2/conversation?limit=2&requestId=750c1e68829f&source=dialogu&hardware=LX01 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/x-www-form-urlencoded\r\n' +
        'Accept-Encoding: gzip, deflate\r\n' +
        'User-Agent: Mozilla/5.0 (Linux; Android 10; 000; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.193 Mobile Safari/537.36 /XiaoMi/HybridView/ micoSoundboxApp/i appVersion/A_2.4.40\r\n' +
        'Referer: https://userprofile.mina.mi.com/dialogue-note/index.html\r\n' +
        'Cookie: userId=434324; serviceToken=b0kaLMUvJIvBYI98j3y+kRA2s69Y0XBj; deviceId=e0ecb30c69d4;\r\n' +
        'Host: userprofile.mina.mi.com\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/device_profile/v2/conversation?limit=2&requestId=750c1e68829f&source=dialogu&hardware=LX01',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: true,
      host: 'userprofile.mina.mi.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    response: {
      status: 401,
      statusText: '',
      headers: [Object [AxiosHeaders]],
      config: [Object],
      request: [ClientRequest],
      data: '<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1></body></html>'
    }
  },
  isError: true,
  code: 'UNKNOWN CODE',
  message: 'UNKNOWN ERROR'
}

重启服务后正常启动,但在前面还有一段报错

root@localhost:~# docker logs -f --tail 100 e7e888b19720
      outputSize: 0,
      writable: true,
      destroyed: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: true,
      socket: [TLSSocket],
      _header: 'GET /device_profile/v2/conversation?limit=2&requestId=b3acdba23bd5&source=dialogu&hardware=LX01 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/x-www-form-urlencoded\r\n' +
        'Accept-Encoding: gzip, deflate\r\n' +
        'User-Agent: Mozilla/5.0 (Linux; Android 10; 000; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.193 Mobile Safari/537.36 /XiaoMi/HybridView/ micoSoundboxApp/i appVersion/A_2.4.40\r\n' +
        'Referer: https://userprofile.mina.mi.com/dialogue-note/index.html\r\n' +
        'Cookie: userId=4324324; serviceToken=vJIvBYI98j3y+kRA2s69Y0XBj; deviceId=45dc-b4b1-e0ecb30c69d4;\r\n' +
        'Host: userprofile.mina.mi.com\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/device_profile/v2/conversation?limit=2&requestId=b3acdba23bd5&source=dialogu&hardware=LX01',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: true,
      host: 'userprofile.mina.mi.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    response: {
      status: 401,
      statusText: '',
      headers: [Object [AxiosHeaders]],
      config: [Object],
      request: [ClientRequest],
      data: '<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1></body></html>'
    }
  },
  isError: true,
  code: 'UNKNOWN CODE',
  message: 'UNKNOWN ERROR'
}
npm error path /app
npm error command failed
npm error signal SIGTERM
npm error command sh -c node ./app.js

npm error A complete log of this run can be found in: /root/.npm/_logs/2024-06-09T23_59_14_122Z-debug-0.log
@idootop
Copy link
Owner

idootop commented Jun 11, 2024

在出错之前你的 docker 大概运行了多久?

@idootop
Copy link
Owner

idootop commented Jun 11, 2024

感觉最近小米查询最新消息的接口很容易超时,可能用这个项目的人开始多起来了。
目前 MiGPT 的默认轮询频率为每秒一次,对服务端的压力来说相对比较友好。
但也说不准哪天官方会给消息接口加上更严格的请求频率限制,且用且珍惜。
后面有空会继续探索能否通过事件通知获取最新消息,进一步减轻服务端的压力。

@shog86
Copy link
Contributor Author

shog86 commented Jun 12, 2024

在出错之前你的 docker 大概运行了多久?

十几个小时

@idootop
Copy link
Owner

idootop commented Jun 12, 2024

401 应该是你帐号信息过期了。不过默认的登录凭证有效期应该是 30 天,你这个才不到 24 小时,有些奇怪。再观察观察吧

@shog86
Copy link
Contributor Author

shog86 commented Jun 12, 2024

现在去跑了一下,容器运行24小时了,日志如下(最后没有服务启动的消息):

root@localhost:~# docker logs -f --tail 100 e7e888b19720
      socket: [TLSSocket],
      _header: 'GET /device_profile/v2/conversation?limit=2&requestId=447be99ac89d&source=dialogu&hardware=LX01 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/x-www-form-urlencoded\r\n' +
        'Accept-Encoding: gzip, deflate\r\n' +
        'User-Agent: Mozilla/5.0 (Linux; Android 10; 000; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.193 Mobile Safari/537.36 /XiaoMi/HybridView/ micoSoundboxApp/i appVersion/A_2.4.40\r\n' +
        'Referer: https://userprofile.mina.mi.com/dialogue-note/index.html\r\n' +
        'Cookie: userId=234343245; serviceToken=sXEJMjSdm6MHG7j4ObihB; deviceId=4b1-e0ecb30c69d4;\r\n' +
        'Host: userprofile.mina.mi.com\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/device_profile/v2/conversation?limit=2&requestId=447be99ac89d&source=dialogu&hardware=LX01',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: [Function: emitRequestTimeout],
      upgradeOrConnect: false,
      parser: [HTTPParser],
      maxHeadersCount: null,
      reusedSocket: true,
      host: 'userprofile.mina.mi.com',
      protocol: 'https:',
      _redirectable: [Circular *1],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: 'https://userprofile.mina.mi.com/device_profile/v2/conversation?limit=2&requestId=447be99ac89d&source=dialogu&hardware=LX01',
    _timeout: null,
    [Symbol(shapeMode)]: true,
    [Symbol(kCapture)]: false
  }
}
getConversations failed {
  error: AxiosError: timeout of 10000ms exceeded
      at RedirectableRequest.handleRequestTimeout (/app/node_modules/.pnpm/axios@1.6.8/node_modules/axios/dist/node/axios.cjs:3123:16)
      at RedirectableRequest.emit (node:events:519:28)
      at Timeout.<anonymous> (/app/node_modules/.pnpm/follow-redirects@1.15.6/node_modules/follow-redirects/index.js:210:12)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7) {
    code: 'ECONNABORTED',
    config: {
      transitional: [Object],
      adapter: [Array],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 10000,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: [Object],
      validateStatus: [Function: validateStatus],
      headers: [Object [AxiosHeaders]],
      proxy: false,
      decompress: true,
      cookies: [Object],
      method: 'get',
      url: 'https://userprofile.mina.mi.com/device_profile/v2/conversation?limit=2&requestId=447be99ac89d&source=dialogu&hardware=LX01',
      data: undefined
    },
    request: Writable {
      _events: [Object],
      _writableState: [WritableState],
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 0,
      _requestBodyBuffers: [],
      _eventsCount: 3,
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [ClientRequest],
      _currentUrl: 'https://userprofile.mina.mi.com/device_profile/v2/conversation?limit=2&requestId=447be99ac89d&source=dialogu&hardware=LX01',
      _timeout: null,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false
    }
  },
  isError: true,
  code: 'ECONNABORTED',
  message: 'timeout of 10000ms exceeded'
}

@idootop
Copy link
Owner

idootop commented Jun 12, 2024

请求超时,正常现象,可以忽略掉。
另外上面日志暴露你的小米账号和设备 id 了,建议删除掉相关 comment,重贴下处理掉隐私信息之后的日志。

image

@shog86
Copy link
Contributor Author

shog86 commented Jun 12, 2024

请求超时,正常现象,可以忽略掉。 另外上面日志暴露你的小米账号和设备 id 了,建议删除掉相关 comment,重贴下处理掉隐私信息之后的日志。

image

我都已经处理过啦,这些id和token,不是原始日志

另外,现在再跑日志,又回到我上次贴的那些了,不断跳,看来得重启一下docker了
重启了服务又启动了

@shog86
Copy link
Contributor Author

shog86 commented Jun 12, 2024

而且我跑日志之前,又在外网登录过一次小米账号了,没跳验证,直接登上了

@8Q757
Copy link

8Q757 commented Jun 13, 2024

+1,目前运行大约 24 小时后,会出现该问题,重启 docker 容器就可以解决

@idootop
Copy link
Owner

idootop commented Jun 13, 2024

@shog86 @8Q757 多谢反馈,应该是登录凭证过期了,现在还没有做 token 自动刷新的机制。如果你们方便的话,最好能提供一下完整的 docker 运行日志还有过期的登录凭证 /app/.mi.json 给我,我本地复现修复下。文件可以打个压缩包,邮件私发给我。

@shog86
Copy link
Contributor Author

shog86 commented Jun 13, 2024

在想是不是注册个小米开发者账号获取个token方便些,比hack C端登录凭证稳定

@idootop
Copy link
Owner

idootop commented Jun 13, 2024

注册个小米开发者账号获取个token

个人应该没有资质。包括现在唤醒模式的曲线救国,也是因为小米小爱开放平台停止了对个人开发者提交小爱技能的申请。

image

现在一点也不开放,对个人开发者很不友好~

@jeffreydyy
Copy link

+1,也是运行大约 20 小时后,掉了,唤醒不了了,大概率也是这问题,重启 docker 容器又可以了

@sped-zhang
Copy link

+1 可能是什么原因导致的?有无解决方法?docker运行一段时间(最长一天)就会报错。

@idootop
Copy link
Owner

idootop commented Jun 14, 2024

@sped-zhang 看现象是登录凭证过期了,下个版本修复(这周末或者下周)。
在此之前你可以通过重启 docker 来缓解这个问题。

@idootop
Copy link
Owner

idootop commented Jun 17, 2024

MiGPT v4.0.0 版本已发布,目测此问题已修复。

@idootop idootop closed this as completed Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants