# Exception occurred in one of response middleware handlers

**URL:** <https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405>\
**Category:** Rasa Open Source\
**Created:** [October 7, 2019, 9:33am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405 "2019-10-07T09:33:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaakku](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kaakku](https://forum.rasa.com/u/kaakku)\
**Post date:** [October 7, 2019, 9:33am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/1 "2019-10-07T09:33:32Z")

</div>

This seems like a bug and I’ve opened a bug report here: [Server sends response once and doesn't respond on subsequent calls. · Issue #4568 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/4568)

If anyone has stumbled upon the same error and been able to resolve it, please do let me know.

Thanks!

---

<div class="post-metadata">

**Author:** ![matthiask](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@matthiask](https://forum.rasa.com/u/matthiask)\
**Post date:** [October 7, 2019, 12:02pm UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/2 "2019-10-07T12:02:41Z")

</div>

This is a problem with the Access-Control-Allow-Origin header. Try to start rasa with the command: "rasa run -m models/20191007-115129.tar.gz --enable-api --log-file out.log --cors \* The problem should be solved then.

---

<div class="post-metadata">

**Author:** ![kaakku](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kaakku](https://forum.rasa.com/u/kaakku)\
**Post date:** [October 7, 2019, 2:29pm UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/3 "2019-10-07T14:29:04Z")

</div>

I did see the `--cors` solution is some other topic as well. However, adding that just suppresses the error log. The problem of empty response being returned on the second call still persists even with the `--cors` option.

---

<div class="post-metadata">

**Author:** ![matthiask](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@matthiask](https://forum.rasa.com/u/matthiask)\
**Post date:** [October 7, 2019, 6:25pm UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/4 "2019-10-07T18:25:45Z")

</div>

Then it’s a problem with the policies. If you write the same message twice, Rasa Core will have a very low confidence score for the second message and will not play a reply. To avoid this, you should also use the FallbackPolicy. If the confidence score is too low, a template defined with the FallbackPolicy will be played.

---

<div class="post-metadata">

**Author:** ![kaakku](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kaakku](https://forum.rasa.com/u/kaakku)\
**Post date:** [October 8, 2019, 12:37am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/5 "2019-10-08T00:37:32Z")

</div>

Hmm… Then shouldn’t that be obvious when `parsing` the same message twice too? However, when making calls to `/model/parse` multiple times with the same message, I get a `"confidence":1.0` each time.

```auto
(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"text":"Im just browsing for fun."}' "http://localhost:5005/model/parse"

{"intent":{"name":"just_browsing","confidence":1.0},"entities":[],"intent_ranking":[{"name":"just_browsing","confidence":1.0},{"name":"wrong_number","confidence":0.0}],"text":"Im just browsing for fun."}%

(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"text":"Im just browsing for fun."}' "http://localhost:5005/model/parse"

{"intent":{"name":"just_browsing","confidence":1.0},"entities":[],"intent_ranking":[{"name":"just_browsing","confidence":1.0},{"name":"wrong_number","confidence":0.0}],"text":"Im just browsing for fun."}%

(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"text":"Im just browsing for fun."}' "http://localhost:5005/model/parse" 

{"intent":{"name":"just_browsing","confidence":1.0},"entities":[],"intent_ranking":[{"name":"just_browsing","confidence":1.0},{"name":"wrong_number","confidence":0.0}],"text":"Im just browsing for fun."}%

```

As for the `/rest/` endpoint, even if I use different messages, it response is empty from the second call onwards. See:

```auto
(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"sender": "Batman", "message":"do not message me"}' "http://localhost:5005/webhooks/rest/webhook"
            
[{"recipient_id":"Batman","text":"My sincere apologies. I will take you off the list right away!"}]

(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"sender": "Batman", "message":"do not message me"}' "http://localhost:5005/webhooks/rest/webhook"

[]%

(unreal) ➜ django git:(test-rasa) ✗ curl -H "Content-Type:application/json" -X POST -d '{"sender": "Batman", "message":"browsing for fun"}' "http://localhost:5005/webhooks/rest/webhook"

[]%

```

---

<div class="post-metadata">

**Author:** ![matthiask](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@matthiask](https://forum.rasa.com/u/matthiask)\
**Post date:** [October 8, 2019, 7:04am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/6 "2019-10-08T07:04:08Z")

</div>

When using the model/parse endpoint, Rasa Core won’t get used. This endpoint is just using the NLU, so no Core confidence score and no policies included. But still weird, that you do not get any responses. Did you try out the solution with the FallbackPolicy?

---

<div class="post-metadata">

**Author:** ![kaakku](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kaakku](https://forum.rasa.com/u/kaakku)\
**Post date:** [October 10, 2019, 1:09am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/7 "2019-10-10T01:09:36Z")

</div>

I see.

And yep, tried with the FallbackPolicy and that keeps returning the action mentioned there despite whatever message I give it.

However, the `Fallback` seems like it should be used just for that purpose itself - a fallback. If we don’t receive a response for the same message that comes in, then it doesn’t really make sense in terms of using this to solve our business problem.

In any case, the issue indeed seems to be a bug which they mentioned they have fixed, but it still hasn’t been fixed: [Server sends response once and doesn't respond on subsequent calls. · Issue #4568 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/4568#issuecomment-539965031)

And sincerely, again, thank you so much for following up and helping out. 🙂

---

<div class="post-metadata">

**Author:** ![kaakku](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kaakku](https://forum.rasa.com/u/kaakku)\
**Post date:** [October 18, 2019, 8:58am UTC](https://forum.rasa.com/t/exception-occurred-in-one-of-response-middleware-handlers/19405/8 "2019-10-18T08:58:55Z")

</div>

Was indeed a bug: [Server sends response once and doesn't respond on subsequent calls. · Issue #4568 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/4568#issuecomment-543115726)
