can you provide an example to start two proxy stub on one mb instance ?

337 views
Skip to first unread message

Xin Cai

unread,
May 23, 2016, 8:09:28 PM5/23/16
to mountebank-discuss
I have two downstream services need to proxy through. Say , http://service1:12345 , and http://service2:23456 

I want to use mb to setup two proxy server which listen on different port number : 4545, and 4646 . How do I config to get this scenario done ? 

currently, I only have one proxy server setup successfully. 

{
"port": 4545,
"protocol": "http",
"stubs": [{
"responses": [{
"proxy": {
"mode": "proxyOnce",
"predicateGenerators": [{
"matches": {
"method": true,
"path": true,
"query": true
}
}]
}
}]
}]
}

Brandon Byars

unread,
May 23, 2016, 10:46:41 PM5/23/16
to Xin Cai, mountebank-discuss
Hi there,
The setup is much the same. The specific answer depends on how you're creating the imposters. If you're using the REST API, then you'd POST the JSON you showed to /imposters, and POST a separate call with similar JSON, but changing the port to 4546 and the proxy/to field to the different URL. If you're using the config file, then it'd be something like this:

{
"imposters": [{
"port": 4545,
"protocol": "http",
"stubs": [{
"responses": [{
"proxy": {
"mode": "proxyOnce",
"predicateGenerators": [{
"matches": {
"method": true,
"path": true,
"query": true
}
}]
}
}]
}]
}, {
"port": 4546,
"protocol": "http",
"stubs": [{
"responses": [{
"proxy": {
"mode": "proxyOnce",
"predicateGenerators": [{
"matches": {
"method": true,
"path": true,
"query": true
}
}]
}
}]
}]
}]
}

Even if you're using the API, you can send a PUT to /imposters with that same payload to do what the two POSTs would do in one call.

Hope that helps - let me know if you need more clarifications.
-Brandon



--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xin Cai

unread,
May 23, 2016, 11:59:40 PM5/23/16
to mountebank-discuss, caixi...@gmail.com
Thanks very much Brandon ~~ !  

在 2016年5月24日星期二 UTC+10下午12:46:41,Brandon Byars写道:
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

princeku...@gmail.com

unread,
May 1, 2018, 10:23:50 PM5/1/18
to mountebank-discuss
> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

We have got a requirement to combine a proxy mode and stub mode in MB. The requirement is that when proxy server is up/running we need to proxy and return expected response. But if the downstream server is down and responding with Internal server error (500) MB should respond in stub mode with a prerecorded/static response.Can anyone provide an insight?

Brandon Byars

unread,
May 2, 2018, 9:15:16 PM5/2/18
to Prince Kuriakose, mountebank-discuss
Hi there,
At the moment, the only way to accomplish this is to use injection. The "inject" response type will work, but requires you to reimplement the proxying logic. What I'd suggest trying instead is to use the "proxy" response type, and adding a "decorator" behavior that looks for a 500 response and replaces it with a static response.
-Brandon

> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

>
> For more options, visit https://groups.google.com/d/optout.

We have got a requirement to combine a proxy mode and stub mode in MB. The requirement is that when proxy server is up/running we need to proxy and return expected response. But if the downstream server is down and responding with Internal server error (500) MB should respond in stub mode with a prerecorded/static response.Can anyone provide an insight?
--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages