orbitdb-archive / orbit-db-http-api

A HTTP API Server for the OrbitDB distributed peer-to-peer database
MIT License
37 stars 11 forks source link

Unknown response from server #48

Open Nortberg opened 2 years ago

Nortberg commented 2 years ago

Hi, I'm a fan of Your project so i have downloaded it and started the server like that node --inspect src/cli.js api --ipfs-host localhost --no-https --orbitdb-dir /xxx/orbitdb or even with certs sudo node src/cli.js api --ipfs-host localhost--no-https --orbitdb-dir /xxx/orbitdb --https-cert /etc/xxx/fullchain.pem --https-key /etc/xxx/privkey.pem

running on port 3000

sending requests; curl http://localhost:3000/dbs > tmpfile.rsp or curl -X POST http://localhost:3000/db/counter -d "create=true" -d "type=counter" > tmpfile.rsp

I get always this; ^@^@^@^D^@^@^@^@^@^@^@^H^G^@^@^@^@^@^@^@^@^@^@^@^@^B

I understand that --no-https parameter is to let OrbitDB API, to connect to ipfs local node without SSL cert. via http: and --https-cert and --https-key is to setup OrbitDB API with https endpoints on port 3000 in that case, and those parameters are not required so I can manage SSL by myself (nginx for example) that lets me improve speed on local environment.

Am I right?

What is interesting I was also trying docker pull orbitdb/orbit-db-http-api:latest docker run --net host orbitdb/orbit-db-http-api src/cli.js api --ipfs-host=127.0.0.1 --no-https --orbitdb-dir=/mnt/disks/ipfs-disk/orbitdb-img or docker run --net host orbitdb/orbit-db-http-api src/cli.js local --no-https --orbitdb-dir=/mnt/disks/ipfs-disk/orbitdb-img and i see the same response; ^@^@^@^D^@^@^@^@^@^@^@^H^G^@^@^@^@^@^@^@^@^@^@^@^@^B

After a while I found that there is a problem with --http2 possibly default config. All is running on Google Cloud Can You guys investigate

phillmac commented 2 years ago

The default is to run with http2 enabled. If you want to disable it the arg is --http1 not --http2. Can you give this a go and report back please?

Nortberg commented 2 years ago

Hi. Thank You for fast response Confirm, --http1 works fine. both docker image and just node. Looks like --http2 in curl version 7.55.1 and 7.58 was playing on my nerves.

Wondering where is the reason; in lib or in my sys config. Can I use some param to run Api in debug mode, [node is not my natural language] This might help me to analyze that in future. LOCAL mode works fine but API not:

As I can see now in api mode; curl -X POST http://127.0.0.1:3000/db/docstore -d "create=true" -d "type=docstore" --output -

Answering with; {"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}

And on api node side; ========started as Docker Opening db docstore IPFSAccessController.save ERROR: { HTTPError: Invalid byte while expecting start of value: 0xa1 at Object.errorHandler [as handleError] (/api/node_modules/ipfs-http-client/src/lib/core.js:67:15) at process._tickCallback (internal/process/next_tick.js:68:7) name: 'HTTPError', response: Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null }, Symbol(Response internals): { url: 'http://127.0.0.1:5001/api/v0/dag/put?format=dag-cbor&input-enc=raw&only-hash=false&hash=sha2-256', status: 500, statusText: 'Internal Server Error', headers: [Headers], counter: 0 } } }

======started as nodejs Server running on port 3000 Opening db docstore IPFSAccessController.save ERROR: HTTPError: Invalid byte while expecting start of value: 0xa1 at Object.errorHandler [as handleError] (/home/gb/orbit-db-http-api/node_modules/ipfs-http-client/src/lib/core.js:67:15) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Client.fetch (/home/gb/orbit-db-http-api/node_modules/ipfs-utils/src/http.js:155:9) at async Object.put (/home/gb/orbit-db-http-api/node_modules/ipfs-http-client/src/dag/put.js:75:17) at async Object.writeCbor [as write] (/home/gb/orbit-db-http-api/node_modules/orbit-db-io/index.js:69:15) at async IPFSAccessController.save (/home/gb/orbit-db-http-api/node_modules/orbit-db-access-controllers/src/ipfs-access-controller.js:46:13) at async Function.create (/home/gb/orbit-db-http-api/node_modules/orbit-db-access-controllers/src/access-controllers.js:68:20) at async OrbitDB._determineAddress (/home/gb/orbit-db-http-api/node_modules/orbit-db/src/OrbitDB.js:334:37) at async OrbitDB.create (/home/gb/orbit-db-http-api/node_modules/orbit-db/src/OrbitDB.js:357:23) at async DBManager.get (/home/gb/orbit-db-http-api/src/lib/db-manager.js:26:22) { response: Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },

  url: 'http://localhost:5001/api/v0/dag/put?format=dag-cbor&input-enc=raw&only-hash=false&hash=sha2-256',
  status: 500,
  statusText: 'Internal Server Error',
  headers: [Headers],
  counter: 0
}

} }

phillmac commented 2 years ago

I can only guess that perhaps the google cloud version of curl is somehow funky? Is it aliased to busybox or something that's not truely curl? Other than that I have no clue.

Nortberg commented 2 years ago

I was using both curl on google console and curl on my ubuntu laptop but now i see that there is some problem like above ''''''''' IPFSAccessController.save ERROR: HTTPError: Invalid byte while expecting start of value: 0xa1 at Object.errorHandler [as handleError] (/home/gb/orbit-db-http-api/node_modules/ipfs-http-client/src/lib/core.js:67:15) ''''''''''

seems like some formatting 0xa1 => 161 =>ansci [~i] Can You help me with that?

spriyabalan commented 1 year ago

I am facing exactly the same issue. Kinldy let me know if you were able to fix his.