cancel
Showing results for 
Search instead for 
Did you mean: 

cl_http_client usage causing Web UI timeout

Former Member
0 Kudos

Hello,

I'm currently running into an issue when triggering a mobile notification (via HTTP post) from Web UI and was wondering if anyone had any experience doing this or thoughts on my issue.

I have it set up to trigger the mobile notification when saving a service request. The notification itself works great and reaches our mobile devices, but afterwards the next action performed in Web UI results in a 500 timeout.

I've determined the issue is caused whenever I close the HTTP connection I opened to send out the notification. If I remove the code which closes the connection, then there is no timeout issue. However, I didn't want to just open the connection then not close it so I wanted to see if anyone knew why it would be timing out.

Here are the relevant portions from my code:

DATA:

           lr_client     TYPE REF TO if_http_client.

* Create URL

       cl_http_client=>create_by_url( EXPORTING url        = lv_device_url

                                      IMPORTING client     = lr_client

                                      EXCEPTIONS

                                        argument_not_found = 1

                                        plugin_not_active  = 2

                                        internal_error     = 3

                                        OTHERS             = 4          ).


       lr_client->request->set_method( 'POST' ).


*     Content Type

       lr_client->request->set_header_field( EXPORTING name  = 'Content-Type'

                                                       value = 'application/xml' ).


*     Authentication

       lr_client->request->set_header_field( EXPORTING name  = 'Authorization'

                                                       value = lv_auth       ).


*     Message to User

       lr_client->request->set_header_field( EXPORTING name  = 'X-SMP-APNS-ALERT'

                                                       value = lv_notif ).

*     Alert Sound

       lr_client->request->set_header_field( EXPORTING name  = 'X-SMP-APNS-SOUND'

                                                       value = 'Default' ).


*      Send Request

       lr_client->send( EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 ).


CALL METHOD lr_client->receive(

         EXCEPTIONS

           http_communication_failure = 1

           http_invalid_state         = 2

           http_processing_failed     = 3 ).



lr_client->close( ).


Any thoughts on this issue would be appreciated. Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

terry_huang
Employee
Employee
0 Kudos

Hi John,

Did you find any solution to solve this problem? I also face to this issue now.

Best regards,

terry

Former Member
0 Kudos

Terry,

I ended up triggering the notifications I was sending out in the background. If I didn't do this, it was always causing a timeout.

I believe the issue stemmed from calling lr_client->close( ) (IF_HTTP_CLIENT) when not called in the background. Even though that method should've just closed the connection I had opened to call my URL, I think it was also altering something in the Web UI connection as well.

So with that said I essentially called the same code I listed above, but within CALL FUNCTION.


*     Send Notification

       CALL FUNCTION 'ZSEND_MOBILE_NOTIF' IN BACKGROUND TASK AS SEPARATE UNIT

         EXPORTING

           iv_url          = lv_device_url

           iv_device_id    = <fs_device>-device_id

           iv_message      = lv_notif

           iv_phone_number = <fs_device>-phone_number.

Let me know if you have any other questions. That's been working in production for almost 2 years now without running into the issue again.