{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Microgateway /
avatar image
0
Question by Lorenzo Acerbo · Jun 19, 2020 at 01:51 PM · 214 Views jsontoxmlbodysoap proxy

Unable to modify request body

Hi, I am trying to write a custom plugin to expose a SOAP Web Service as REST API.

I read the docs and I managed to convert from json to correct SOAP request, but when it comes to send the request to the target service I get this error

{"message":"write after end","code":"ERR_STREAM_WRITE_AFTER_END"}

To be sure that it was not my plugin's fault, I tried with a fresh installation (I'm using latest version 3.1.4 on a docker container), with only one plugin activated: accumulate-request. I configured httpbin.org as target service, so I can inspect what flows out from MG.

When I send a POST request with no body, everything works as expected and httpbin respond correctly, but as I try to put something in the body I get the same error as above (here with the full stack trace):

2020-06-19T13:25:49.439Z gateway:main targetRequest error 64038cb0-b230-11ea-b7ce-4582586cfc80 Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at write_ (_http_outgoing.js:637:17)
at ClientRequest.write (_http_outgoing.js:629:15)
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:434:35
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1154:26
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:380:13
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:269:32
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:377:17
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1150:21
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:167:37
at fx (/usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:579:25)
at onend_request (/usr/local/lib/node_modules/edgemicro/node_modules/microgateway-plugins/accumulate-request/index.js:36:7)
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:596:31
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1149:20
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:375:13
2020-06-19T13:25:49.439Z gateway:main plugin analytics does not provide handler function for error_request
2020-06-19T13:25:49.439Z gateway:main plugin accumulate-request does not provide handler function for error_request
2020-06-19T13:25:49.440Z gateway:errors Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at write_ (_http_outgoing.js:637:17)
at ClientRequest.write (_http_outgoing.js:629:15)
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:434:35
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1154:26
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:380:13
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:269:32
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:377:17
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1150:21
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:167:37
at fx (/usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:579:25)
at onend_request (/usr/local/lib/node_modules/edgemicro/node_modules/microgateway-plugins/accumulate-request/index.js:36:7)
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/lib/plugins-middleware.js:596:31
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:1149:20
at /usr/local/lib/node_modules/edgemicro/node_modules/microgateway-core/node_modules/async/lib/async.js:375:13

The same thing happens with any plugins that send anything as body at the end of onend_request chain, like, for example, json2xml.

This seems like a bug, to me. Is there anybody able to use one of this plugin out of the box?

Any help is very appreciated.

Cheers

Lorenzo

Comment
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Robin Martin   · Nov 27, 2020 at 06:31 PM 0
Link

Howdy Lorenzo - did you come right?
If so, please share RCA ... otherwise one thing to consider is the execution order of events.

Where you have multiple plugins in a sequence, I have yet to be able to correctly implement async processing .... you may be able to confirm same by adding (console/log) displays in your plugins ... to check if the processing has actually continued to the next plugin .... before you get your (callout) response and try to write to the body.
I have lost many hours trying - so obviously I must be doing something wrong because it doesn't seem to work as advertised, LOL :) .

Close

0 Answers

  • Sort: 

Follow this Question

Answers Answers and Comments

65 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get the request body within onrequest(req, res, next) method? 1 Answer

Microgateway - Delete Operation with Body 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges