cancel
Showing results for 
Search instead for 
Did you mean: 

ReadyAPI as a client of server sent events

SOLVED
Highlighted
New Contributor

ReadyAPI as a client of server sent events

Hello,


I need to use ReadyAPI as a client of server sent events.

Indeed, after sending a request I need to listen to event data (as a result of my request)  and  retrieve event data sent on SSE.

I'm using ReadyAPi pro version

 

Thanks a lot for your help

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Hey @Rose,

I did a bit of reading about server side events and it seems pretty straightforward (once id done some reading and reviewed the curl command youve specified anyway!)

The events handlers in ReadyAPI! do something different and i think youre letting the word "event" obfuscate the issue, so id just ignore those for now.

Just to ensure im clear in regards to your understanding, you have some SSE component (which equates to Server Side Events if googled) which you poke via curl, this initiates a connection allowing multiple (>=1) push messages to be returned from the endpoint and the Content-Type of these >=1 messages is set as 'text/event-stream' correct?

That seems quite straightforward (without knowing anything about that particular datatype). I don't know what the -N switch does (other than disabling stuff) but the -H switch appears to set the Accept header value.

You just need to setup your REST request as you would any other if converting a curl request to ReadyAPI!
Im guessing here but id setup a GET request using the following endpoint and URI (https://localhost:8080/request/listen) and ensure you add the 'Accept' header parameter (there doesnt appear to be any other REST parameters defined according to your post) with the value of 'text/event-stream' to the request.

You havent mentioned any authentication scheme in your post so you might need to tailor that, but your endpoint is local so the above is at least the startoff point to setup your requests in ReadyAPI! with a view toward automation. Still a bit concerned about the -N switch and what this is actually setting, but without knowing any further info about what youre testing, you should be able to start setting it up in ReadyAPI!

Hope the above helps,

Nice one,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

Highlighted
New Contributor

Hello,

The proposed approach does not work.

I have addressed my question to smartbear customer service and they have  provided me a solution. 

ReadyAPI (sopaui pro) doesn't support the SSE technology but we can implement the SSE logic inside a Groovy Script test step.

To do that, we can use any Java library that supports SSE. Here is an example:
https://golb.hplar.ch/2018/02/Access-Server-Sent-Events-from-Java.html

 

It works now 🙂 

View solution in original post

7 REPLIES 7
Highlighted
Community Hero

Can you further define what "Server sent events" means? That's a phrase that can mean any sort of different types of events and messages. The more details you can provide the better chances that we can help!




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
New Contributor

Thanks for your response.

 

I testing an API using SSE channel to send  messages.

Manually I test data events sent on SSE with curl client this way:

curl -N -H "Accept: text/event-stream" https://localhost:8080/request/listen

I need to do the same test with ReadyAPI. (listening and tracking  “event-stream” sent by the server after the request has been submitted)

 

I have noticed that there's an event handler in ReadyAPi but I'm not sure if it can help.

I'm quite blocked to automate this part with Ready API

 

Thanks a lot

 

 

Highlighted
Community Hero

Hey @Rose,

I did a bit of reading about server side events and it seems pretty straightforward (once id done some reading and reviewed the curl command youve specified anyway!)

The events handlers in ReadyAPI! do something different and i think youre letting the word "event" obfuscate the issue, so id just ignore those for now.

Just to ensure im clear in regards to your understanding, you have some SSE component (which equates to Server Side Events if googled) which you poke via curl, this initiates a connection allowing multiple (>=1) push messages to be returned from the endpoint and the Content-Type of these >=1 messages is set as 'text/event-stream' correct?

That seems quite straightforward (without knowing anything about that particular datatype). I don't know what the -N switch does (other than disabling stuff) but the -H switch appears to set the Accept header value.

You just need to setup your REST request as you would any other if converting a curl request to ReadyAPI!
Im guessing here but id setup a GET request using the following endpoint and URI (https://localhost:8080/request/listen) and ensure you add the 'Accept' header parameter (there doesnt appear to be any other REST parameters defined according to your post) with the value of 'text/event-stream' to the request.

You havent mentioned any authentication scheme in your post so you might need to tailor that, but your endpoint is local so the above is at least the startoff point to setup your requests in ReadyAPI! with a view toward automation. Still a bit concerned about the -N switch and what this is actually setting, but without knowing any further info about what youre testing, you should be able to start setting it up in ReadyAPI!

Hope the above helps,

Nice one,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

Highlighted
Community Manager

msiadak, richie - thank you!

 

Hi @Rose, have you tried the proposed approach? Let us know how you solved the issue.


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
New Contributor

Hello,

The proposed approach does not work.

I have addressed my question to smartbear customer service and they have  provided me a solution. 

ReadyAPI (sopaui pro) doesn't support the SSE technology but we can implement the SSE logic inside a Groovy Script test step.

To do that, we can use any Java library that supports SSE. Here is an example:
https://golb.hplar.ch/2018/02/Access-Server-Sent-Events-from-Java.html

 

It works now 🙂 

View solution in original post

Highlighted
Community Hero

Hey @Rose,

Its great that youve got your issue sorted but seeing as it doesnt look like anyone on the forums seen SSE stuff before, rather than just posting a link to a page and saying youve wrapped up the code in a groovy step, could you provide a bit more info as to your test case setup (was it just a single groovy test step containing java or multiple groovy steps? Etc.) and which code you implemented in the end as there are a couple of options described in the link.

The lower level details would be invaluable to anyone else attempting to do this in the future.

Cheers!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
New Contributor

Can you provide a solution of how to add a Groovy Script so that we can test SSE from SoapUI.  The link that was provided is interesting but does not give enough detail to add the test.

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors