Skip to content

Stateless StreamableHTTPServerTransport is still stateful? #360

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

Open
cramforce opened this issue Apr 18, 2025 · 11 comments
Open

Stateless StreamableHTTPServerTransport is still stateful? #360

cramforce opened this issue Apr 18, 2025 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@cramforce
Copy link

Hey,

I'm probably missing something, but it appears that StreamableHTTPServerTransport._initialized represents inter-request state as shown here

I need to hit the same transport between the initial GET and subsequent POST

Image

Meanwhile the sample code makes a new transport object on every request which yields "not yet initialized" errors

Image

Are fully stateless server transports supported?

@cramforce cramforce added the bug Something isn't working label Apr 18, 2025
@rinormaloku
Copy link

I think it is not, even in a fully stateless mode, the StreamableHTTPServerTransport requires getting the first initialization request.

@wong2
Copy link

wong2 commented Apr 18, 2025

Yeah, the current example of stateless server doesn't work

@wong2
Copy link

wong2 commented Apr 18, 2025

I think for a stateless server, it shouldn't be mandatory to require initialization.

@wong2
Copy link

wong2 commented Apr 18, 2025

Related #335

@ihrpr
Copy link
Contributor

ihrpr commented Apr 18, 2025

@cramforce thank you for creating this issue!

yes, the example is wrong, fixed it.

Full example is here.

note, please use the latest release (1.10.1)

@ihrpr
Copy link
Contributor

ihrpr commented Apr 18, 2025

I think for a stateless server, it shouldn't be mandatory to require initialization.

@wong2 the initialization is required for capabilities negotiations regardless if it's a stateful or a stateless server

@rinormaloku
Copy link

rinormaloku commented Apr 18, 2025

@ihrpr QQ: if there are multiple replicas, and your client initializes with the first replica but its second request is load balanced to the second replica (which still didn't initialize) what is the expected result? (The actual result is that it fails)

How is this stateless or how can statelessness be achieved with this protocol?

Note: The documented approach Stateless Mode doesn't work. And you can easily run the same server twice, and put a load balancer in front with a round robin algorithm, and you will see that it won't work.

@wong2
Copy link

wong2 commented Apr 18, 2025

Another duplicated issue: #330

@wong2
Copy link

wong2 commented Apr 18, 2025

I think the problem is that the Server itself IS stateful, which stores attributes like _clientCapabilities and _clientVersion that are related to a specific client.

@cramforce
Copy link
Author

Yeah, with the .1 and updated example it works with a single server replica.

I'd even say that with multiple replicas it appears now all replicas eventually get into good state but requests fail if a replica has never seen an initialization request.

I think a cleaner design which would force things to work in both simple and complex examples would be where the stateless server/transport gets constructed per request (and garbage collected). That way it is absolutely clear that it is truly stateless

@ihrpr
Copy link
Contributor

ihrpr commented Apr 19, 2025

@cramforce #335 should address init state failure on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants