Flow JS SDK Error: Response closed without headers

Hey everyone,
I’m using Flow JS SDK on the backend. When running this script:

const response = await sdk.send(await sdk.build([
      await sdk.getAccount(testNodeAddress)
    ]), { node: testNetNode })

it shows an error no matter what I do:
Error: Response closed without headers

Even when I switch the arguments to Flow Emulator Address and Node.

But when I use the Mainnet Node (I don’t have a Mainnet account btw.) it returns this:
Error: address XXXXXXXXXXX is invalid for chain flow-mainnet

Is it possible that the Local and Testnet nodes are not accepting the grpc connections from JS-SDK and/or FCL?

@JeffreyDoyle @gregsantos Could you take a look at this? Thanks!

I think this issue should now be fixed.

Tnx @sideninja @flowjosh . Has it been deployed yet? Because I’m getting the same errors…
@onflow/sdk - npm is showing the version 0.0.45

Which address do you use for testnet node?

I’m using https://access.devnet.nodes.onflow.org:9000
But it doesn’t work with either

Hi dh77 :wave: :grinning_face_with_smiling_eyes:,

To remedy this issue, you’ll need to point the JS-SDK to use the HTTP proxy that is exposed in front of the Access APIs for MainNet, TestNet and the Flow Emulator.

The addresses that you might want to use are:

MainNet: https://access-mainnet-beta.onflow.org
TestNet: https://access-testnet.onflow.org
Emulator: (May be different on your machine. Please reference what’s outputted from the emulator when it’s started as thats when it will output the address you’ll need.)

The issue you ran into is what happens when the JS-SDK is given an address that corresponds to the GRPC service on each Access API. Since the JS-SDK works in a JavaScript environment, it needs to communicate to an Access API via HTTP, which is why we expose an HTTP proxy in front of each Access API. We’re working on improving our tooling to make this error more intuitive in the future!

Tnx @JeffreyDoyle that works now :slight_smile: You should definitely put that into the JS-DSK Docs

@JeffreyDoyle Hi, I ran into same issue, how to point the JS-SDK to use the HTTP proxy? I was trying to check SDK docs. Thanks!

Hi there - you can point your FCL to HTTP Proxy by replacing the endpoints in your config for the Access API.

You can find more on how to set the values for the configuration here.

For example, in your case you might use:

   .put("accessNode.api", "https://access-testnet.onflow.org")

To provide context on the difference between access.devnet.nodes.onflow.org:9000 and https://access-testnet.onflow.org. The first one is a grpc binary protocol, while the latter is the https proxy of the grpc binary protocol. The js-sdk needs to work in both the browser and node, so because browsers can’t do proprietary binary protocols we have to talk to the access nodes via the https-proxy.