Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jun 04 16:21
    dalcantara commented #732
  • Jun 04 10:06
    amankapoor27 commented #733
  • Jun 04 07:53
    bkabrda commented #793
  • Jun 04 06:49

    jamesdbloom on master

    removed dependency on sun.secur… fixed destination port and ip i… (compare)

  • Jun 03 20:49

    jamesdbloom on master

    added ability to switch between… (compare)

  • Jun 03 18:26
    jamesdbloom commented #793
  • Jun 03 15:55
    MahatmaFatalError closed #779
  • Jun 03 15:55
    MahatmaFatalError commented #779
  • Jun 03 13:30
    bkabrda opened #793
  • Jun 03 07:36
    aman-inbetween commented #733
  • Jun 03 07:18
    jamesdbloom commented #733
  • Jun 03 07:17
    jamesdbloom commented #733
  • Jun 03 07:11
    skydetulliov commented #733
  • Jun 03 06:24
    jamesdbloom labeled #750
  • Jun 03 06:24
    jamesdbloom labeled #750
  • Jun 03 06:24
    jamesdbloom assigned #750
  • Jun 03 06:24
    jamesdbloom commented #750
  • Jun 03 05:56

    jamesdbloom on master

    minor performance tweaks added version to log output to … (compare)

  • Jun 03 05:53
    jamesdbloom assigned #779
  • Jun 03 05:53
    jamesdbloom labeled #779
Asif Ameer
@meveno try the template response format and use JSON.parse(request.body.string).<yourfield> within the javascript.
Manuel EVENO
ok I'll try this ! Thanks
anyone here?
Rajendra Prasad Reddy Penumalli
How to add an expectation ( via REST interface) to match certain headers and and ignoring any other headers ? Is it possible? I don't find this example or capability for mock server for this feature.
James D Bloom
@/all This chat group is migrating to Slack if you would like to join the new Slack group please use the following link
There will in due course be an auto-join page but for now the two ways to join the new slack group is to either use this link which expires in 30 days or send an email to
Parag Somani

Hello @jamesdbloom

I was able to run the mock-server successfully using docker container. I was able to create expectation and access via REST interface successfully.

Can you assist, how can i persist created expectation, so that even after restart, i should be able to access them.

P.S. I have tried mounting volume to docker container, but did not have luck. Looks like i am missing something.

James D Bloom
@/all @paragsomani This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
James D Bloom
@paragsomani there is no current support for persisting expectations because typically MockServer expectations are created inside the test using them, long-running expectations is an anti-pattern for tests because this introduces coupling and break encapsulation making those tests more complex and harder to debug, there, however, other use cases where persisted expectations could help, such as when a service is not yet available but integration development can't wait, so this item is on the backlog: to persistence expectations
Parag Somani
thank you @jamesdbloom
Hey, I'm using the mockserver to return an xml response with a custom mediatype. The xml has the encoding flag utf8. Everything is working fine if the contenttype is declared as application/xml. However if you use application/my.type+xml I'm receiving a RuntimeException (java.lang.RuntimeException: [was class] Invalid UTF-8 middle byte 0x4c (at char #961, byte #54)). The mockserver does not return the xml utf8 encoded. If you add the charset=utf8 to the custom mediatype it is working again. I think the mockserver should support the mediatye application/*+xml.
James D Bloom
@Chr3is This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
@Chr3is which version of MockServer are you using? I have just improved the handling of content-type header formats, but it would be good to ensure there is a test covering your exact format. Can you please tell the exact string your using for content-type?
James D Bloom
@Chr3is the new parsing logic can happily handle application/my.type+xml, application/my.type+xml;charset=utf-8 or application/my.type+xml; Charset="utf-8" without any issue
this logic is available in version 5.8.0 (the latest version)
And the response is utf8 encoded? The spring web client who handled the response had the problem if the xml string I wanted to return contained chars like the german Ö or Ä. The media type was something like application/
@jamesdbloom I will take a look at the version tomorrow
James D Bloom
@Chr3is If you still having any issue please respond on Slack and also provide the MockServer log output so I can see what is happening.
Will do this tomorrow at work. We compared the response in an hex editor and the Ö wasnt utf8 encoded which leaded to the CharConversionException
Evan Brodie

Hello Mockserver community.

I would like to know if it is possible to build a Mockserver Expectation where a value of the HTTP Response can be dynamically created based on a value from the HTTP Request. I'm thinking something like capturing a regex match from the request and putting that captured value into the response.

My use case is that I want to match all requests to a particular route, but I want to capture the query parameters. I then want to be able to have these query parameters stored in an HTTP header in my response (in my specific case, the Location header).

Is this currently possible in Mockserver? I am using the API client right now. Thank you.

James D Bloom
@ecbrodie This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
Hello Mockserver community, I am new to MockServer and new to java. I have been trying to initialize expectations using the initializationClass configuration property 'java -Dmockserver.initializationClass="org.mockserver.server.initialize.ExpectationInitializerExample" -jar ~/Downloads/mockserver-netty-5.9.0-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO', I have changed the path to jar to my local path, but did not change the initializationClass, I got an error 'java.lang.RuntimeException: java.lang.ClassNotFoundException: ExpectationInitializerIntegrationExample'. What should I do to fix this? Thanks!
James D Bloom
@JuneWangC This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
@JuneWangC you can only use an initializationClass if it is in the classpath of the JVM otherwise it won't be visible to MockServer, if you run MockServer in embedded mode using the org.mockserver.integration.ClientAndServer class from within the same project containing the initialiser then you should find that easier, see:
@jamesdbloom Thanks for answering, I have joined the Slack group, thank you

Hello I am getting closed web socket connection the very first time the tests are run on a linux machine,
ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog WARNING Client 26f5fe02-ef57-488f-bc8f-74b6c8d118df not found for request ed-api_1 | ed-api_1 | { ed-api_1 | "method" : "GET", ed-api_1 | "path" : "/ws/v1/persons", ed-api_1 | "queryStringParameters" : { ed-api_1 | "uupid" : [ "alice" ] ed-api_1 | }, ed-api_1 | "headers" : { ed-api_1 | "accept-encoding" : [ "gzip" ], ed-api_1 | "user-agent" : [ "ReactorNetty/0.8.12.RELEASE" ], ed-api_1 | "host" : [ "ed-api:1080" ], ed-api_1 | "accept" : [ "*/*" ], ed-api_1 | "content-length" : [ "0" ], ed-api_1 | "WebSocketCorrelationId" : [ "bcf16e0e-035a-426f-8629-e1c35a9125ac" ] ed-api_1 | }, ed-api_1 | "keepAlive" : true, ed-api_1 | "secure" : false ed-api_1 | } ed-api_1 | ed-api_1 | client registry only contains ed-api_1 | ed-api_1 | {26f5fe02-ef57-488f-bc8f-74b6c8d118df=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0x61d82abe, L:ed-api/ - R:/]), 1ae4ae2c-d978-4cb1-9697-167016647d96=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0xca1b173c, L:ed-api/ - R:/]), 8f41ac93-f5f0-4033-8e27-4bd927bae4f0=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0xb391485f, L:ed-api/ - R:/])} ed-api_1 | ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog WARNING Returning ed-api_1 | ed-api_1 | { ed-api_1 | "statusCode" : 404, ed-api_1 | "reasonPhrase" : "Not Found" ed-api_1 | } ed-api_1 | ed-api_1 | because client 26f5fe02-ef57-488f-bc8f-74b6c8d118df has closed web socket connection ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog INFO returning response:

So even though the match was found, im getting a 404, because of this, happens only the first time, and runs fine the second time. Any idea why this might happen?

James D Bloom
@haripri-vt This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
Hi everyone. I get a timeout error trying to get requests on the following code from the examples. I increased the timeout to 60 sec set through ConfigurationProperties.maxSocketTimeout, but it did not help
HttpRequest[] recordedRequests = new MockServerClient("serverIp", 1080) .retrieveRecordedRequests( request() );
[ERROR] Time elapsed: 42.308 s <<< FAILURE!
org.mockserver.client.SocketCommunicationException: Response was not received from MockServer after 35000 milliseconds, to wait longer please use "mockserver.maxSocketTimeout" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)
But getting the same information through api works - checked in postman. http://serverIp:1080/mockserver/retrieve?type=REQUESTS
What could be the problem?
James D Bloom
@HarryHoudini This chat group has migrated to Slack if you would like to join the new Slack group please use the following link
Robertino Aniello
Hi, what's the difference on docker hub between mockserver/mockserver repository and jamesbloom/mockserver repository? Which one should I use? Both refers to the same documentation but the documentation refers to mockserver/mockserver even if the latter has 1M+ pulls agains 100K+ of the official one
Julian B.
Hi everyone, I'm using MockServer to mock 50MB json responses. After a fixed number of responses (iirc ~25 responses), MockServer responds with 404 and then a short while later I get "Exception in thread "MockServer-EventLog0" java.lang.OutOfMemoryError: Java heap space". My mock is using a callback with a fixed static buffer, so I'm not creating it at every invocation of the callback. Is there something simple I can do to avoid this? MockServer is in a separate process, right? So how can I, from my junit rule, configure the heap size of the other process? Or is there something I can do to optimize the memory usage?
hi I created an expectation that mock-server gets a POST request with a gzipped body but when i actually send it a gzipped body the expectation fails. I also dont see my content-type : gzip header in mock-server logs. Is it because mock-server automatically unzips the body ?
Hem Chand


I am facing an issue in apache http configuration.

Requirement :

A request has land on apache with some header.

for example :

Header myToken

Url https://localhost/fetch-r

Response new Url https://localhost/fetch-r?id=myToken

How can i achieve this in Apache Http 2.4 ?

can any one help me here ?