web stats
Http sender at localhost http web service - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2019, 09:52 AM
common_user common_user is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 6
common_user is on a distinguished road
Cool Http sender at localhost http web service

Hello.
I have a rest web service developped on my machine, it's url is "http:// localhost/SomeApi/persons". When this channel runs, the destination makes a get request at "/SomeApi/persons" which results in a not authorized error. This is the same if I use 127.0.0.1 instead of localhost.

I tested with an external API, found somewhere on the internet, and the call is made correct. Why is that? Is there something about mirth that dictates this? I want to see the complete flow of a message which involves multiple destinations, some of which are of type HTTP senders, but no HTTP sender works with calls on the local machine. Why would it refuse to make calls to a perfectly valid web service url and instead cut a piece out of that url?

I read the whole user guide, is there something in it that I missed?

Thank you.

Last edited by common_user; 10-20-2019 at 11:48 AM.
Reply With Quote
  #2  
Old 10-21-2019, 08:23 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 219
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

I love using Postman to test my APIs. It gives you a TON of control and debugging output so you can see what's going on.
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #3  
Old 10-21-2019, 01:22 PM
common_user common_user is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 6
common_user is on a distinguished road
Default

I did use Postman to test the same API as in the http sender. And it works ok with it, postman receives success status. I compared the same request with postman and mirth and the only difference between the two was the mirth request lacks "http://localhost" from the url. Because of this, it results in not authorized error.

So now I am trying to understand why mirth alters the url.
Reply With Quote
  #4  
Old 10-21-2019, 02:44 PM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 219
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

"localhost" can only be used on the same computer that is running the server. e.g. if you are using postman on the mirth server. if you are using postman on YOUR PC, but the mirth server is different, you must use the server's IP.
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #5  
Old 10-21-2019, 10:33 PM
common_user common_user is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 6
common_user is on a distinguished road
Default

I'm sorry, I did not explain the problem correctly. Both mirth server and the web service are on my computer, the development machine. Also Postman is on the same machine. All of them are on the dev machine.
The url is the same in both postman and http sender. The problem is, while postman accomplishes the get request successfully, mirth fails and receives unauthorized error. I reproduced both cases with wireshark, and the only difference between them is that in mirth's case, the get is is missing the "http://localhost" from the url. Everything else is the same, headers, query params.

So my question is why soes mirth decide to alter the url when the url contains localhost or 127.0.0.1?

By the way, when i test mirt with 127.0.0.1 instead of localhost, it does the same thing and gets the "http://127.0.0.1" out of the url, so it receives the same error.

The altering of the url is done at message processing time, at channel designing time the url is saved correctly on the destination.
Reply With Quote
  #6  
Old 10-22-2019, 07:30 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 219
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Mirth doesn't really care about the IP. I might have an internal IP of "10.2.3.4" but to the internet, It's 45.2.6.13. The IP doesn't affect the innerworkings of the API. I'm not sure what you have going on with your authentication, but it SHOULDN'T have anything to do with what IP it's coming in on...
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #7  
Old 10-22-2019, 01:20 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,005
agermano is on a distinguished road
Default

https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

Section 5.1.2 explains that it is still a valid request. Mirth (actually apache HttpClient) is sending the abs_path where you are expecting the absoluteURI.

Quote:
To allow for transition to absoluteURIs in all requests in future versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI form in requests, even though HTTP/1.1 clients will only generate them in requests to proxies.

You might need to adjust your authentication to support both.
Reply With Quote
  #8  
Old 10-22-2019, 01:36 PM
common_user common_user is offline
Mirth Newb
 
Join Date: Oct 2019
Posts: 6
common_user is on a distinguished road
Default

Oh... so you are saying nothing is wrong with the url with absolute path and this might actually be an authentication issue. Well ok. I will investigate this further. Thank you.
Reply With Quote
Reply

Tags
http sender

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:35 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation