Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with @aws-sdk/client-kinesis (v3) #118

Open
alesmenzel opened this issue Jun 8, 2022 · 3 comments
Open

Does not work with @aws-sdk/client-kinesis (v3) #118

alesmenzel opened this issue Jun 8, 2022 · 3 comments

Comments

@alesmenzel
Copy link

Hi,
the library does not seem to work with the v3 AWS SDK for Node.

"@aws-sdk/client-kinesis": "^3.105.0",

Here is a sample repro:

const { KinesisClient, ListStreamsCommand } = require('@aws-sdk/client-kinesis')

const main = async () => {
	const client = new KinesisClient({
		region: 'us-west-1',
		endpoint: 'http://localhost:4567',
		credentials: {
			accessKeyId: 'accessKeyId',
			secretAccessKey: 'secretAccessKey',
		},
	})
	try {
		await client.send(
			new ListStreamsCommand({
				Limit: 1,
			})
		)
	} catch (err) {
		console.log(err)
		process.exit(1)
	} finally {
		client.destroy()
	}
}

main()

and I am getting this vague error

Error [ERR_HTTP2_ERROR]: Protocol error
    at new NghttpError (node:internal/http2/util:555:5)
    at Http2Session.onSessionInternalError (node:internal/http2/core:784:26) {
  code: 'ERR_HTTP2_ERROR',
  errno: -505,
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

if I enable the SSL option for kinesalite (npx kinesalite --port=4567 --createStreaMs=5 --ssl) then I get

Error: Unexpected error: http2 request did not get a response
    at ClientHttp2Stream.<anonymous> (.../node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js:105:28)
    at ClientHttp2Stream.emit (node:events:390:28)
    at emitCloseNT (node:internal/streams/destroy:138:10)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

when I try to connect to kinesalite with aws cli then it seems to work (no SSL only)

$ aws --endpoint-url=http://localhost:4567 kinesis list-streams --region eu-west-1
{
    "StreamNames": [] // I have not created any, so this is correct
}

I believe this to be a bug in kinesalite.

@garyhuntddn
Copy link

Just hit the same - it appears that kinesalite supports HTTP/1.1 but doesn't support HTTP/2

@garyhuntddn
Copy link

If you're still interested @alesmenzel then you can do the following to force the v3 SDK to use an HTTP/1.1 connection.

...

import { NodeHttpHandler } from "@aws-sdk/node-http-handler";

...

const kinesisConfig: KinesisClientConfig = {
  ...
  requestHandler: new NodeHttpHandler()
};
const kinesisClient = new KinesisClient( kinesisConfig );

@vweevers
Copy link

FYI, the package @aws-sdk/node-http-handler has been deprecated and replaced with @smithy/node-http-handler. So the above workaround is now:

import { NodeHttpHandler } from "@smithy/node-http-handler";

const kinesisConfig: KinesisClientConfig = {
  ...
  requestHandler: new NodeHttpHandler()
};
const kinesisClient = new KinesisClient( kinesisConfig );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants