Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed 'Forwarded' should produce 502 if upstream unavailable #568

Open
Evynglais opened this issue Nov 30, 2022 · 2 comments
Open

Failed 'Forwarded' should produce 502 if upstream unavailable #568

Evynglais opened this issue Nov 30, 2022 · 2 comments

Comments

@Evynglais
Copy link

Evynglais commented Nov 30, 2022

Describe the bug

Failing to forward a SOAP request using 'Forwarded' status should result in a 502 error, rather than a 500 'Internal Server Error'.

To Reproduce
Steps to reproduce the behavior:

  1. Configure any SOAP (REST untested) endpoint as a 'Forwarded' endpoint to an unavailable SOAP server.
  2. Send in a request - a JSON response will be received with a statusCode 500 'Internal Server Error'.
  3. Viewing the logs will show the following message:
2022-11-30 11:17:31.930 ERROR 1 --- [nio-8080-exec-2] o.s.b.w.s.s.ErrorPageFilter              : Forwarding to error page from request [/mock/soap/project/K1FFaC/imcesp] due to exception [Unable to forward request to configured endpoint]

com.castlemock.web.mock.soap.model.SoapException: Unable to forward request to configured endpoint
        at com.castlemock.web.mock.soap.controller.mock.AbstractSoapServiceController.process(AbstractSoapServiceController.java:142) ~[web-mock-soap-1.63.jar:?]
        at com.castlemock.web.mock.soap.controller.mock.SoapServiceController.postMethod(SoapServiceController.java:67) ~[web-mock-soap-1.63.jar:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]

Expected behavior
A statusCode 502 indicating an upstream gateway problem, and an error message indicating as such.

Desktop (please complete the following information):

  • OS: Official Docker image running on Windows 11
  • Browser: N/A
  • Version: 1.63

WSDL files or other resource attachments:
Unable to share due to company policy.

@karldahlgren
Copy link
Collaborator

Hi @Evynglais!
The first thing I would recommend you to try is to change the mocked service setting to mocked and then verify that the client actually can invoke that service.

If the mocked service works and it is just to forwarding functionality that does not work then it could be any of these problems:

  • Invalid forwarded URL
  • No access to the forwarded URL
  • The forwarded URL is using a self-signed SSL certificate. Java could block request towards services that are using self-signed SSL certificates.

Hope you find this answer helpful. Have a nice day!

@Evynglais
Copy link
Author

Hi,

Sorry if I wasn't clear. The failure is expected; the issue is that castlemock returns a 500 status code rather than the correct 502 indicating an upstream gateway problem.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants