简体   繁体   English

数据快照 session 已过期

[英]Datasnap session has expired

I've been using client server application using datasnap... Everything works flawlessly until server is restarted.我一直在使用使用 datasnap 的客户端服务器应用程序......在服务器重新启动之前,一切都完美无缺。 Once server is restarted client has to be restarted as well.一旦服务器重新启动,客户端也必须重新启动。 If do not restart client, client can't communicate with server because of annoying issue "session has expired".如果不重新启动客户端,客户端无法与服务器通信,因为烦人的问题“会话已过期”。 Who faces same issue?谁面临同样的问题? How to solver?如何求解? Thanks谢谢

I've created example project to clarify what I mean.我创建了示例项目来阐明我的意思。 Download link下载链接

Steps to reproduce the issue:重现问题的步骤:

  1. Open ProjectGroup1.groupproj打开 ProjectGroup1.groupproj
  2. Compile and run rest project.编译并运行 rest 工程。 It's server是服务器
  3. Compile and run client project.编译并运行客户端项目。
  4. Click start button on rest project单击 rest 项目上的开始按钮
  5. Click button1 on client project.单击客户端项目上的 button1。 It will call rest EchoString method它将调用 rest EchoString 方法
  6. Click stop button on rest project单击 rest 项目上的停止按钮
  7. Click start button on rest project单击 rest 项目上的开始按钮
  8. Click on button1 on client project.单击客户端项目上的 button1。 You have to get "Session has expired" issue你必须得到“会话已过期”的问题

Ok, It seems I found a solution.好的,看来我找到了解决方案。

On client side just set TDSRestConnection.PreserveSessionID=False.在客户端只需设置 TDSRestConnection.PreserveSessionID=False。 I suppose every request will have new session id, thus it will never expire...我想每个请求都会有新的 session id,因此它永远不会过期......

TDSRestConnection.PreserveSessionID=False

It is an easy way to create a new session each time, but it can put unnecessary stress on the server.每次创建一个新的 session 是一种简单的方法,但它会给服务器带来不必要的压力。

When a session timeout occurs, it is better to initialize the session with the code below and request again.当发生 session 超时时,最好使用下面的代码初始化 session 并再次请求。

TDSRestConnection.SessionID := '';

Handling the client like this and properly adjusting the server's session timeout time can make the server more effective.像这样处理客户端并适当调整服务器的 session 超时时间可以使服务器更有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM