deeplay-io / nice-grpc

A TypeScript gRPC library that is nice to you

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[nice-grpc-web] UNKNOWN: Transport error: NetworkError

RobertAron opened this issue Β· comments

I'm having problems setting up a minimal example of the web client. I have an example here:

https://github.com/RobertAron/nice-grpc-web-minimum-example

In the example, I set up a server, and a web-client + a node-client. The node client works, but the web client does not.

I'm getting this error from the browser:

ClientError: /nice_grpc.myCoolPageNameSpace.MyApi/GetHello UNKNOWN: Transport error: NetworkError when attempting to fetch resource.
fetchTransport@webpack-internal:///./node_modules/nice-grpc-web/lib/client/transports/fetch.js:40:32

Screenshot 2023-03-30 at 3 16 43 AM

I think the UNKNOWN problem was fixed in another MR, but I tried with older versions which didn't help.

I don't think it's an envoy problem because it's not logging anything at all, so I don't think the request is even getting that far.

Hey,

Try to check the Network tab in the browser devtools. Also the browser may log some extra info to the console.

Browsers report very little info to exceptions thrown from fetch.

The network tab doesn't have anything relevant as far as I can tell. Just things related to nextjs.

Screenshot 2023-03-30 at 12 36 10 PM

I see this error in the browser console:

Fetch API cannot load localhost:8080/nice_grpc.myCoolPageNameSpace.MyApi/GetHello. URL scheme "localhost" is not supported.

Try to change createChannel("localhost:8080") to createChannel("http://localhost:8080").

That did it! I can't believe I missed that. Thanks so much! I appreciate it!! πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰