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

1 Like

@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!

1 Like

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.

I haven’t gotten things to work yet but now that I found this thread I’ll give it another try. Updating the js sdk docs with an example would be greatly appreciated!

This might be a dumb question but are the past sporks still accessible? If so, are there https proxys available for those past sporks that we can use for js-sdk calls? When I look at the past sporks page I just see the access node with 9000 port.

I was going through unrelated github issues searching for a different question, and I stumbled on this

Screen Shot 2022-01-28 at 11.06.45 AM

So as of March 2021, there weren’t any http proxies for the past sporks, but I’m not sure if this has changed?

Hi there - unfortunately you have to use different urls and possibly versions of the sdk to query past sporks. I believe a community member has created a proxy service to query events of past sporks you can get in touch with.

Here is the discord link. His Discord tag is - NedRyerson#4922

Did you already sort out how to query events from past sporks? I have an http proxy service I have built that lets me query events from any spork (except for a few really old ones that aren’t currently available), I can help you set that up if you’re interested

1 Like

thanks I’ve moved to alchemy for now, they must have implemented something similar to what Ned did

Oh yes - Alchemy API has super awesome features like that as well! Glad you found a working soltuion. If you have any feedback for the Alchemy API - don’t hesitate to share!