線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2614
推到 Plurk!
推到 Facebook!

REST Service 的壓力測試時發生讀不到 RemoteIP 的問題

缺席
GrandRURU
站務副站長


發表:240
回覆:1680
積分:1874
註冊:2005-06-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2014-01-24 17:34:21 IP:59.120.xxx.xxx 訂閱
主要是在 DSServer.Connect 事件發生的問題
我的 Code 如下:

[code delphi]procedure TWebModule2.DSServer1Connect(
DSConnectEventObject: TDSConnectEventObject);
begin
TDSSessionManager.GetThreadSession.PutData('RemoteAddr', string(Request.RemoteAddr));
end; [/code]

在 Client 連續開啟關閉連線下

有時 Request.RemoteAddr 會出現以下兩種情況:
1. Empty String
2. Except: Privileged instruction

請問是我這行程式有問題嗎?在 XE - XE5 Update 2 下都會有上述的問題

附件中測試專案請用 XE 以上版本開啟,謝謝。

1/25 更新,此問題也同時上傳到 EMBT QC 中
Request not access in DSServer.OnConnect Event
DSServer can not get the Client IP

1/28 更新,看來屬於 EMBT 的 BUG ,但修正時間不明。
不過還是有一半解:
Thread: How to get Datasnap Client IP adress by Mathew DeLong

它是這麼寫的:
To obtain the IP when a client is connecting, you can add an OnConnect event to the TDSServer component. In the event, get the IP with this code:
IPAddress := DSConnectEventObject.ChannelInfo.Info

You could then store the IP address in the current session, for later use. To do this, use the following code:
TDSSessionManager.GetThreadSession.PutData('RemoteIP', IPAddress);

However, this may not be necessary, as the IP may already be stored in the session.

To get the IP from the session from within a server method, call this (requiring the DSService unit):
TDSSessionManager.GetThreadSession.GetData('RemoteIP')
編輯記錄
GrandRURU 重新編輯於 2014-01-24 17:35:30, 註解 無‧
GrandRURU 重新編輯於 2014-01-24 17:54:14, 註解 無‧
GrandRURU 重新編輯於 2014-01-25 22:17:44, 註解 無‧
GrandRURU 重新編輯於 2014-01-28 03:20:34, 註解 無‧
GrandRURU 重新編輯於 2014-01-28 10:50:53, 註解 無‧
系統時間:2024-04-20 4:00:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!