How to capture signalR connection string in Jmeter

纵然是瞬间 提交于 2019-12-24 10:49:43

问题


I am getting error when script is executed in jmeter, because of signalr connection

I need to pass connectionToken and connectionData in the url as below.

"/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=${connectionToken}&connectionData=${connectionData}"

i am able to capture ConnectionToken and passing that successfully. but, i am facing issue with connectionData, which looks like

[{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]

How to capture and pass this. Please find the screeshots

! enter image description here

! enter image description here

! enter image description here

! enter image description here

not able to capture below connection string

connectionData: [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]

get method sends above connectionData as

GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635

and am getting the response connectionToken. i am able to extract connectionToken .

now, i need to send

GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26_%3D1522754518635

It has valid connectionToken(extracted) but not the connectionData.

Response is Unexpected character encountered while parsing value: %. Path '', line 0, position 0.

my question is how can i get this values, [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}].

and next i need to post

POST //abc.com/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU+P9fDasBFDTA+78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG+CsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635

as you can see here, it has valid connectionToken but not connectionData.

Response for this is : The ConnectionId is in the incorrect format.

BlazeMeter1

Blazemeter2

Blazemeter3


回答1:


You need to use the same method as you have used for connection token. It seems like your variable is not getting the required values. Are you using the same variables between two thread groups?

**-->Here request is encoded and connection data is also encoded.**
GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=**%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D**&_=1522754518635

and am getting the response connectionToken. i am able to extract connectionToken .

now, i need to send

**-->Here again encoded connection data is further encoded.**
GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=**%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26**_%3D1522754518635

If I got it correct, then avoid encoding twice. In first and second screenshot you are encoding it twice. If "connectionData" is fixed then try "User defined variables" or if it is available in some response then capture there using regular expression and use it further. I hope you are not getting error during data extraction.



来源:https://stackoverflow.com/questions/49648779/how-to-capture-signalr-connection-string-in-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!