Cannot log in under a proxy environment - v5.6.2

Bug report

image

I cannot log in under a proxy environment.
This is similar to a problem you have solved for me before.

I execute this now.

const axios = require('axios')
process.env.http_proxy = YOUR_PROXY_HTTP_URL
process.env.https_proxy = YOUR_PROXY_HTTPS_URL

axios.get('https://api.inkdrop.app/')
  .then(function (response) {
    console.log(response.data)
  })
  .catch(function (error) {
    console.log(error)
  })

It will cause an error.

GET https://api.inkdrop.app/ net::ERR_TUNNEL_CONNECTION_FAILED 407 (Proxy Authentication Required)

I execute this now.

const fetch = require('node-fetch');
const HttpsProxyAgent = require('https-proxy-agent');
const options = {
  agent: new HttpsProxyAgent('http://PROXY_SERVER_URL/')
}

fetch('https://api.inkdrop.app/', options)
    .then(function (response) {
        console.log('Response with axios was ok: ' + response.status);
    })
    .catch(function (error) {
        console.error(error);
    });

It will cause an error.

Uncaught Error: Cannot find module ‘node-fetch’

Are there other ways to investigate this?

Environment

  • Platform: windows
  • Platform version: 10
  • App Version: 5.6.2
1 Like

When launching the app with --enable-logging option, what do you get?

/Applications/Inkdrop.app/Contents/MacOS/Inkdrop --enable-logging

You should get a log something like:

app:info axios default config: { proxy: ***, httpAgent: ***, httpsAgent: *** }

(見られたくないものは消してるはず・・・)

2023-11-24T02:50:39.953Z app:info Arguments: C:\Users\@@@@@@@@@\AppData\Local\inkdrop\app-5.6.2\Inkdrop.exe
2023-11-24T02:50:39.955Z app:info Arguments: --enable-logging
2023-11-24T02:50:39.959Z app:info Creating app window
2023-11-24T02:50:40.148Z app:info Initializing inkdrop app..
2023-11-24T02:50:40.149Z app:info Starting inkdrop app..
2023-11-24T02:50:40.150Z app:info http proxy enabled: http://@@@@@@%40@@@@@@:password@proxy.com:8080
2023-11-24T02:50:40.150Z app:info https proxy enabled: http://@@@@@@%40@@@@@@:password@proxy.com:8080
2023-11-24T02:50:40.151Z app:info axios default config: {
  proxy: undefined,
  httpAgent: HttpProxyAgent {
    _events: [Object: null prototype] {
      free: [Function (anonymous)],
      newListener: [Function: maybeEnableKeylog]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    options: [Object: null prototype] { noDelay: true, path: null },
    requests: [Object: null prototype] {},
    sockets: [Object: null prototype] {},
    freeSockets: [Object: null prototype] {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256,
    scheduling: 'lifo',
    maxTotalSockets: Infinity,
    totalSocketCount: 0,
    proxy: URL {
      href: 'http://@@@@@@%40@@@@@@:password@proxy.com:8080',
      origin: 'http://proxy.com:8080',
      protocol: 'http:',
      username: '@@@@@@%40@@@@@@',
      password: 'password',
      host: 'proxy.com:8080',
      hostname: 'proxy.com',
      port: '8080',
      pathname: '/',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    },
    proxyHeaders: {},
    connectOpts: { host: 'proxy.com', port: 8080 },
    [Symbol(kCapture)]: false,
    [Symbol(AgentBaseInternalState)]: {}
  },
  httpsAgent: HttpsProxyAgent {
    _events: [Object: null prototype] {
      free: [Function (anonymous)],
      newListener: [Function: maybeEnableKeylog]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    options: { path: undefined },
    requests: [Object: null prototype] {},
    sockets: [Object: null prototype] {},
    freeSockets: [Object: null prototype] {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256,
    scheduling: 'lifo',
    maxTotalSockets: Infinity,
    totalSocketCount: 0,
    proxy: URL {
      href: 'http://@@@@@@%40@@@@@@:password@proxy.com:8080',
      origin: 'http://proxy.com:8080',
      protocol: 'http:',
      username: '@@@@%40@@@@',
      password: 'passoword',
      host: 'proxy.com:8080',
      hostname: 'proxy.com',
      port: '8080',
      pathname: '/',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    },
    proxyHeaders: {},
    connectOpts: {
      ALPNProtocols: [Array],
      host: 'proxy.com',
      port: 8080
    },
    [Symbol(kCapture)]: false,
    [Symbol(AgentBaseInternalState)]: {}
  }
}
2023-11-24T02:50:40.176Z app:info Starting a session
2023-11-24T02:50:40.180Z app:warn Failed to load account from file: Error: ENOENT: no such file or directory, open 'C:\Users\@@@\AppData\Roaming\inkdrop/account'
    at Object.openSync (node:fs:601:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
    at Object.readFileSync (node:fs:469:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9212)
    at C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:112165
    at Object.load (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:112313)
    at oe.init (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:64235)
    at g.init (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:51117)
    at Se.start (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:77807)
    at z (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:111736)
2023-11-24T02:50:40.704Z app:warn Failed to load account from file: Error: ENOENT: no such file or directory, open 'C:\Users\@@@\AppData\Roaming\inkdrop/encryption-key'
    at Object.openSync (node:fs:601:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
    at Object.readFileSync (node:fs:469:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9212)
    at C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:71623
    at Object.load (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:71763)
    at oe.isLoggedIn (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:67393)
    at async oe.getAccountStatusLocal (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:68015)
    at async g.init (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:51132)
    at async Se.start (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:77788)
2023-11-24T02:50:40.706Z app:error error during auto update: undefined
2023-11-24T02:50:40.752Z app:warn Failed to load account from file: Error: ENOENT: no such file or directory, open 'C:\Users\@@@\AppData\Roaming\inkdrop/encryption-key'
    at Object.openSync (node:fs:601:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
    at Object.readFileSync (node:fs:469:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9212)
    at C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:71623
    at Object.load (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:71763)
    at oe.isLoggedIn (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:67393)
    at async oe.getAccountStatusRemote (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:69357)
    at async g.checkAccountActiveness (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:52224)
    at async g.init (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:51184)
2023-11-24T02:50:41.278Z app:warn Failed to load account from file: Error: ENOENT: no such file or directory, open 'C:\Users\@@@\AppData\Roaming\inkdrop/account'
    at Object.openSync (node:fs:601:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
    at Object.readFileSync (node:fs:469:35)
    at t.readFileSync (node:electron/js2c/asar_bundle:2:9212)
    at C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:112165
    at Object.load (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:112313)
    at g.getSessionState (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\app.asar\main.js:1:51727)
    at C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\node_modules\@electron\remote\dist\src\main\server.js:465:71
    at IpcMainImpl.<anonymous> (C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\node_modules\@electron\remote\dist\src\main\server.js:323:27)
    at IpcMainImpl.emit (node:events:513:28)
[14492:1124/115052.008:INFO:CONSOLE(113)] "app:warn Session is not active. Abort checking for plugin updates. +0ms", source: C:\Users\@@@\AppData\Local\inkdrop\app-5.6.2\resources\node_modules\debug\src\common.js (113)

とするとproxyの設定は正しく適用されているように見えますね。
なんでだろう

以下のコードを NodeJS (18.15.0) + axios (1.4.0) で手元で動かすとどうなりますか?

const axios = require('axios')
const HttpsProxyAgent = require('https-proxy-agent');
const HttpProxyAgent = require('http-proxy-agent');

const apiConfig= {
  baseURL: 'https://api.inkdrop.app/',
  proxy: undefined,
  httpsAgent: new HttpsProxyAgent('http://PROXY_SERVER_URL/'),
  httpAgent: new HttpProxyAgent('http://PROXY_SERVER_URL_FOR_HTTP_SITES/')
}
const apiClient = axios.create(apiConfig)
apiClient.get('/').then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.error(error);
  })

実行方法が正しいのか自信が無いですが
Inkdrop のログイン画面からコンソール起動で実行した場合も
ローカルで (node 18.18.2 + axios 1.4.0) で試した場合も

TypeError: HttpsProxyAgent is not a constructor

となります。ローカル ↓

 TypeError: HttpsProxyAgent is not a constructor
    at Object.<anonymous> (C:\repos\nodeproto\index.js:8:15)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47

ローカルの package.json

{
  "name": "nodeproto",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "1.4.0",
    "http-proxy-agent": "^7.0.0",
    "https-proxy-agent": "^7.0.2"
  }
}

ああすみません、v7でdefault exportじゃなくなっていました。

const axios = require('axios')
const { HttpsProxyAgent } = require('https-proxy-agent');
const { HttpProxyAgent } = require('http-proxy-agent');

const apiConfig= {
  baseURL: 'https://api.inkdrop.app/',
  proxy: undefined,
  httpsAgent: new HttpsProxyAgent('http://PROXY_SERVER_URL/'),
  httpAgent: new HttpProxyAgent('http://PROXY_SERVER_URL_FOR_HTTP_SITES/')
}
const apiClient = axios.create(apiConfig)
apiClient.get('/').then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.error(error);
  })

inkdrop のコンソールからですが、ネットワークエラーになります。

ローカル実行時

AxiosError: read ECONNRESET
    at AxiosError.from (C:\repos\nodeproto\node_modules\axios\dist\node\axios.cjs:836:14)
    at RedirectableRequest.handleRequestError (C:\repos\nodeproto\node_modules\axios\dist\node\axios.cjs:3010:25)
    at RedirectableRequest.emit (node:events:517:28)
    at eventHandlers.<computed> (C:\repos\nodeproto\node_modules\follow-redirects\index.js:14:24)
    at ClientRequest.emit (node:events:517:28)
    at Socket.socketErrorListener (node:_http_client:501:9)
    at Socket.emit (node:events:517:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  syscall: 'read',
  code: 'ECONNRESET',
  errno: -4077,
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function], Blob: [class Blob] },
    validateStatus: [Function: validateStatus],
    headers: AxiosHeaders {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/1.4.0',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    baseURL: 'https://api.inkdrop.app/',
    httpsAgent: HttpsProxyAgent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      options: [Object],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype] {},
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 0,
      proxy: [URL],
      proxyHeaders: {},
      connectOpts: [Object],
      [Symbol(kCapture)]: false,
      [Symbol(AgentBaseInternalState)]: {}
    },
    httpAgent: HttpProxyAgent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype],
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      proxy: [URL],
      proxyHeaders: {},
      connectOpts: [Object],
      [Symbol(kCapture)]: false,
      [Symbol(AgentBaseInternalState)]: [Object]
    },
    method: 'get',
    url: '/',
    data: undefined
  },
  request: <ref *1> Writable {
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    _events: [Object: null prototype] {
      response: [Function: handleResponse],
      error: [Function: handleRequestError],
      socket: [Function: handleRequestSocket]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: Infinity,
      protocol: 'http:',
      path: 'https://api.inkdrop.app/',
      method: 'GET',
      headers: [Object: null prototype],
      agents: [Object],
      auth: undefined,
      family: undefined,
      lookup: undefined,
      beforeRedirect: [Function: dispatchBeforeRedirect],
      beforeRedirects: [Object],
      hostname: 'proxy.com',
      port: '8080',
      agent: [HttpProxyAgent],
      nativeProtocols: [Object],
      pathname: 'https://api.inkdrop.app/'
    },
    _ended: true,
    _ending: true,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 0,
    _requestBodyBuffers: [],
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: false,
      _closed: false,
      socket: [Socket],
      _header: 'GET https://api.inkdrop.app:8080/ HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'User-Agent: axios/1.4.0\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Proxy-Authorization: Basic @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=\r\n' +
        'host: api.inkdrop.app\r\n' +
        'Proxy-Connection: close\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [HttpProxyAgent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: 'https://api.inkdrop.app:8080/',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'proxy.com',
      protocol: 'http:',
      _redirectable: [Circular *1],
      [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://api.inkdrop.app/',
    [Symbol(kCapture)]: false
  },
  cause: Error: read ECONNRESET
      at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
    errno: -4077,
    code: 'ECONNRESET',
    syscall: 'read'
  }
}

ローカルでも再現できたけど、エラーの内容が ECONNRESET なんですね。奇妙ですね。
ローカル実行時エラーの以下の行が気になりました:

path: 'https://api.inkdrop.app:8080/'

なんでAPIへのエンドポイントのポートまでproxyの8080になってるんだろう。
これってaxios最新の 1.6.2 でも再現できるでしょうか?

documentationを読むかぎりagentの指定方法は間違ってなさそうですが:

503 になりました。

AxiosError: Request failed with status code 503
    at settle (C:\repos\nodeproto\node_modules\axios\dist\node\axios.cjs:1967:12)
    at IncomingMessage.handleStreamEnd (C:\repos\nodeproto\node_modules\axios\dist\node\axios.cjs:3062:11)
    at IncomingMessage.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1368:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_BAD_RESPONSE',

proxy と agent を両方指定したら行けたという報告があるようです。

そちらの環境で直接デバッグ出来たら良いのですが、難しいですね。

@plugin-developer Does anyone have a web proxy environment? We are struggling to solve the strange error when it is behind a web proxy with v5.6.2. Any help would be appreciated.

If you are in a web proxy, please try running this with NodeJS 18.18.2 + axios 1.4.0:

const axios = require('axios')
const { HttpsProxyAgent } = require('https-proxy-agent');
const { HttpProxyAgent } = require('http-proxy-agent');

const apiConfig= {
  baseURL: 'https://api.inkdrop.app/',
  proxy: undefined,
  httpsAgent: new HttpsProxyAgent('http://PROXY_SERVER_URL/'),
  httpAgent: new HttpProxyAgent('http://PROXY_SERVER_URL_FOR_HTTP_SITES/')
}
const apiClient = axios.create(apiConfig)
apiClient.get('/').then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.error(error);
  })

and if you could reproduce an error, please let me know a workaround.

よく分からないんですが、 proxy に指定するポート番号でリクエストが飛んでいるようなので
↓ で プロキシを経由しなくても外に出られる端末を経由して 443 に書き換える proxy 経由でリクエストすると https://api.inkdrop.app/ からは ok が返ってきました。

package main

import (
	"fmt"
	"log"
	"net/http"
    "net"
	"github.com/elazarl/goproxy"
)

func main() {
    proxy_port := ":3128"
	proxy := goproxy.NewProxyHttpServer()
	proxy.Verbose = true
	proxy.OnRequest().DoFunc(
        func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
            fmt.Println("---------------------------")
            fmt.Println(r.RequestURI)
            // URL から現在のホストとポートを取得
            host, _, err := net.SplitHostPort(r.URL.Host)
            if err != nil {
                // ポートが明示されていない場合は、err が発生する可能性があります
                host = r.URL.Host
            }
            // ポート番号を変更(例えば、8080 に変更)
            newPort := "443"
            r.URL.Host = net.JoinHostPort(host, newPort)

            // プロキシを通してリクエストを継続
            return r, nil
        })

    fmt.Println(proxy_port)
	log.Fatal(http.ListenAndServe(proxy_port, proxy))
}

ただ、Inkdrop からは 200 で返ってくるものの

read ECONNRESET Please check your system configuration or report the problem.

でエラーになりました。

proxy のログ

2023/11/24 19:15:55 [001] INFO: Got request /account api.inkdrop.app:3128 GET https://api.inkdrop.app:3128/account?dataVersion
=4.7.0&clientVersion=5.6.2&encrypt=true
---------------------------
https://api.inkdrop.app:3128/account?dataVersion=4.7.0&clientVersion=5.6.2&encrypt=true
2023/11/24 19:15:55 [001] INFO: Sending request GET https://api.inkdrop.app:443/account?dataVersion=4.7.0&clientVersion=5.6.2&
encrypt=true
2023/11/24 19:15:56 [001] INFO: Received response 200 OK
2023/11/24 19:15:56 [001] INFO: Copying response to client 200 OK [200]
2023/11/24 19:15:56 [001] INFO: Copied 1024 bytes to client error=<nil>
2023/11/24 19:15:56 [002] INFO: Got request /account/api-keys/_e2ee api.inkdrop.app:3128 PUT https://api.inkdrop.app:3128/acco
unt/api-keys/_e2ee
---------------------------
https://api.inkdrop.app:3128/account/api-keys/_e2ee
2023/11/24 19:15:56 [002] INFO: Sending request PUT https://api.inkdrop.app:443/account/api-keys/_e2ee
2023/11/24 19:15:57 [002] INFO: Received response 200 OK
2023/11/24 19:15:57 [002] INFO: Copying response to client 200 OK [200]
2023/11/24 19:15:57 [002] INFO: Copied 307 bytes to client error=<nil>

うーん

よく分からなくなってきたんですが・・・。

const proxy_url = "会社のプロキシ"
const axios = require("axios");
const { HttpsProxyAgent } = require("https-proxy-agent");
const { HttpProxyAgent } = require("http-proxy-agent");

// キャッシュを無効にするヘッダーを設定
const noCacheHeaders = {
  "Cache-Control": "no-cache, no-store, must-revalidate",
  Pragma: "no-cache",
  Expires: "0",
};

const apiConfig = {
  baseURL: "https://api.inkdrop.app:443/",
  proxy: undefined,
  httpsAgent: new HttpsProxyAgent(proxy_url),
  httpAgent: new HttpProxyAgent(proxy_url),
  headers: noCacheHeaders,
};
const apiClient = axios.create(apiConfig);
apiClient
  .get("/")
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.error(error);
  });
  1. Inkdrop を起動してコンソールから 実行 → NG
  2. ターミナルから node index.js で実行 → OK
  3. 再度、Inkdrop のコンソールから実行 → OK

どちらにしても Inkdrop にログインはできないんですけど。

わかったかも

Can you please try this patch?

  • Upgraded axios to latest
  • Do not use ProxyAgents but use the environment variables instead to configure the proxy for axios

https://inkdrop-dist.s3.ap-northeast-1.amazonaws.com/tmp/Inkdrop-5.6.2-Windows_patch-1.zip

I’ve tested it with a web proxy server in my network and confiemd that it works properly.

ダメでした・・・。

一回目のログイン

Error message:
  socket hang up Please check your system configuration or report the problem.
Status code:
  N/A

二回目以降のログイン

Error message:
  Request failed with status code 407 - Sorry, possible under maintenance. Please try again later. Check our twitter @inkdrop_app for the current status.
Status code:
  407

それは謎ですね🤔 手元のWindows 11環境では上手くproxy経由でアクセス出来ています。
今一度 config.json を確認、ターミナルから実行、proxy設定が効いていることを確認してください。
それでも動かない場合は、shimizuさんが書いたpythonのスクリプトで得たログを見せていただけますか?

(一旦、今の状況ですが)
以前と同じで、 go の ↓ なローカル実行のプロキシを通すと、今回の patch でログインできました。
http_proxy と https_proxy は環境変数にあります。

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/elazarl/goproxy"
)

func main() {
	port := ":3128"
	proxy := goproxy.NewProxyHttpServer()
	proxy.Verbose = true
	proxy.OnRequest().DoFunc(
		func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
			return r, nil
		})
	fmt.Println(port)
	log.Fatal(http.ListenAndServe(":3128", proxy))
}

config.json

      "network": {
        "http_proxy": "http://localhost:3128",
        "https_proxy": "http://localhost:3128"
      },

ログイン後は今回のパッチ無し exe で
プロキシを通常の会社プロキシに戻してもノートの同期ができます。

↓ config.json を戻す

      "network": {
        "http_proxy": "http://あかうんと%40どめいん:ぱすわーど@プロキシサーバー:8080",
        "https_proxy": "http://あかうんと%40どめいん:ぱすわーど@プロキシサーバー:8080"
      },
      "themes": [

  • パッチ版 → goプロキシ → APIサーバ

では上手くログイン出来るという事ですね。
アプリとgoのリクエストの違いはなんだろう。
少なくとも手元では動いているので、環境依存の問題の可能性が高いです。
socket hang upになったり407が出たり結果が変わるって事は、プロキシサーバ自体に接続できたり出来なかったりしている?

データベースとの通信はaxiosではなくnode-fetchを使っています。こちらの挙動は問題なさそうですね。
axiosはこの辺の動作が不安定なので将来的には全部node-fetchに乗り換えたい所ですが、改修範囲が広いので中長期的な計画になりそうです。

  • パッチ版 → goプロキシ → 会社プロキシ → APIサーバ

になるかと。

node で実行した場合と、inkdrop のコンソールで実行した場合とで影響を与えあってるようにも見えるので環境っぽいのですが、謎ですねぇ・・・・。

もうちょっと見てみます。