# HttpMessageHandler Request Done and Error

**URL:** <https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082>\
**Category:** Bug Reports\
**Created:** [June 9, 2015, 9:39pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082 "2015-06-09T21:39:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 9, 2015, 9:39pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/1 "2015-06-09T21:39:19Z")

</div>

Hi, im doing some http request that works perfect on Fuse preview and in Android devices, but in iOS, when i do the same request (and almost any request) the event Error is trigered along side with the Done request.

In IOS in the previous version of Fuse this work fine!

So, i trigger the request, it loads everything and then the function linked to Error is triggered.

im using Error as a “No Conection” error, i know that i should be using Timeout, but that doesnt work neither.

What can it be? How i can fix it?

```auto
void httpRequest(){

    string urlreqDetalle = "(URL DELETED)";
    urlreqDetalle = urlreqDetalle += apiKey;

    HttpMessageHandler msgdetalle = new HttpMessageHandler();

    var requestdet = msgdetalle.CreateRequest("GET", urlreqDetalle);

    requestdet.Done += DetallesPelicula;

    requestdet.Error += Error;

    requestdet.GetResponseContentString().ToString();

    requestdet.HttpResponseType = HttpResponseType.String;

    requestdet.SendAsync();

}

* Fuse version 0.1.2577

```

---

<div class="post-metadata">

**Author:** ![Joao\_Abecasis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/joao_abecasis/32/221_2.png) [@Joao\_Abecasis](https://forums.fusetools.com/u/Joao_Abecasis)\
**Post date:** [June 11, 2015, 1:27pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/2 "2015-06-11T13:27:13Z")

</div>

Hi, thanks for your bug report! The Http package saw a rewrite on both iOS and Android, so it’s likely that some new issues were introduced. If I understand correctly, you are seeing both Done and Error firing for the same request – Is this right?

I haven’t been able to reproduce that particular issue, but I posted a sample application I wrote at: [https://gist.github.com/biochimia/fea40facb64b2f3efb20](https://gist.github.com/biochimia/fea40facb64b2f3efb20)

Can you modify the example so it reproduces the issue you are seeing? I want to get a better understanding of the conditions under which the issue triggers.

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 11, 2015, 1:58pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/3 "2015-06-11T13:58:45Z")

</div>

Thanks Joao,

Yes, I am seeing both Done and Error firing for the same request. Or sometimes only error. The problem only happens on iPhone, and the requests involved in this problem are requests to [parse.com](http://parse.com). this problem only appeared on the newest version of Fuse, on the old one worked fine (using [Experimental.Net](http://Experimental.Net)).

My app does http request to 2 different servers using REST API, one is [parse.com](http://parse.com) and the other is [themoviedb.org](http://themoviedb.org), the problem is only when it make a request to [parse.com](http://parse.com).

---

<div class="post-metadata">

**Author:** ![Joao\_Abecasis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/joao_abecasis/32/221_2.png) [@Joao\_Abecasis](https://forums.fusetools.com/u/Joao_Abecasis)\
**Post date:** [June 12, 2015, 8:58am UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/4 "2015-06-12T08:58:17Z")

</div>

I dug a little bit more and found a leak and a potential memory corruption bug, which I’ll fix, but I’m not sure this would consistently cause the issue you are seeing. I’ll leave you with a few questions for now.

- Does the issue surface if you only make requests to [parse.com](http://parse.com)?
- How much data is being transferred or do you expect to be transferred per request?
- Do you keep references to requests you send? And, if so, do you access the response’s content string outside the event handlers? (Doing this would currently make you vulnerable to the memory corruption issue I found on iOS)

Any other information you can share about the requests and feel is relevant in this case?

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 12, 2015, 1:05pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/5 "2015-06-12T13:05:47Z")

</div>

Q.-Does the issue surface if you only make requests to [parse.com](http://parse.com)? A.-Only with [parse.com](http://parse.com) and only on iOS.

Q.-How much data is being transferred or do you expect to be transferred per request? A.-Im only requesting some data from the database, the biggest request is like 16 vars and one of it is an array of strings that for now contain only 2 strings, that and i have a limit of 3.

Q.-Do you keep references to requests you send? And, if so, do you access the response’s content string outside the event handlers? (Doing this would currently make you vulnerable to the memory corruption issue I found on iOS) A.- i have all the vars on the void. this is the request:

Code not displaying correctly, ill repost it

what that does is get all the data from the database, add it to a new list and send the data to another class to append it to one stackpanel to dsplay the list. Everytime it is called, the stackpanel is cleared

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 12, 2015, 1:10pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/6 "2015-06-12T13:10:32Z")

</div>

```
void ReqMyMoviesAccount(string UserId){
    try{
    QueError = "ReqMyMoviesAccount";
    TriggerLoadingMyAccount.On = true;
    HttpMessageHandler MyMoviesList = new HttpMessageHandler();
    var createRequ = MyMoviesList.CreateRequest("GET","https://api.parse.com&order=-createdAt&count=1&limit=3&skip="+SkipValor); createRequ.SetHeader("Content-type", "application/json");
    createRequ.SetHeader("X-Parse-Application-Id","");
    createRequ.SetHeader("X-Parse-REST-API-Key","");
    createRequ.Done += ResMyMoviesAccount;
    createRequ.Error += Error;
    createRequ.GetResponseContentString();
    createRequ.SetResponseType(HttpResponseType.String);
    createRequ.SendAsync();
    }catch(Exception e){
        debug_log e;
    }
}
void ResMyMoviesAccount(HttpMessageHandlerRequest request){ try{
      SkipValor = SkipValor + 3;
      bool LikedByMe=false;
      var respJson = request.GetResponseContentString();
      var jsonSerialized = JsonReader.Parse(respJson);
      var MyMovieList = new List<MyMovies>();
      if(jsonSerialized["results"].Count != 0){
          for(int i = 0; i < jsonSerialized["results"].Count;i++){
              TotaldePeliculasP = jsonSerialized["count"].AsInteger();
            var MyMoviesRes = jsonSerialized["results"][i];
            var idPelicula = MyMoviesRes["IdPelicula"].AsString();
            var Ano = MyMoviesRes["Ano"].AsString();
            var Comentario = MyMoviesRes["Comentario"].AsString();
            var Valor = MyMoviesRes["Valoracion"].AsFloat();
            var date = MyMoviesRes["createdAt"].AsString();
            var PosterPath = MyMoviesRes["PosterPath"].AsString();
            var FramePath = MyMoviesRes["FramePath"].AsString();
            var Likes = MyMoviesRes["Likes"].AsInteger();
            var objectId = MyMoviesRes["objectId"].AsString();
            var NombrePelicula = MyMoviesRes["NombrePelicula"].AsString();
            var NombreUser = MyMoviesRes["FullName"].AsString();
            var UserName = MyMoviesRes["UserName"].AsString();
            var UserImg = MyMoviesRes["UserProfilePic"].AsString();
            var UserId = MyMoviesRes["UserId"].AsString();
            for(int a=0; a<MyMoviesRes["UsersLiked"].Count; a++){
                if(UserIdLoggedInApp == MyMoviesRes["UsersLiked"][a].AsString()){
                    LikedByMe = true;
                }
            }
            MyMovieList.Add(new MyMovies(idPelicula, NombrePelicula, PosterPath, FramePath, objectId, Ano, Valor, Likes, date, Comentario, NombreUser, UserImg, LikedByMe, UserId, UserName));
            LikedByMe = false;
        }
        foreach(var ml in MyMovieList){
            var displaymovies = new Movie{
                ml = this,
                MovieId = ml.MovieId,
                MovieNombre = ml.MovieNombre,
                MovieFrame = ml.MovieFrame,
                MovieObjectId = ml.MovieObjectId,
                MovieAno = ml.MovieAno,
                MovieValor = ml.MovieValor,
                MovieLikes = ml.MovieLikes,
                MovieDate = ml.MovieDate,
                MovieComent = ml.MovieComent,
                MoviePoster = ml.MoviePoster,
                NombreUser = ml.NombreUser,
                UserImg = ml.UserImg,
                Liked = ml.Liked,
                UserId=ml.UserId,
                UserName=ml.UserName,
            };
            MyMoviesPosts.AddChild(displaymovies);
        }
      }else{
      }
      }catch(Exception e){
          debug_log e;
      }
      TriggerLoadingMyAccount.On = false;
      seguroRefreshScroll = false;
}

```

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 24, 2015, 4:02pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/7 "2015-06-24T16:02:16Z")

</div>

Any news about this? My app in IOS dont work!

Thanks!

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 24, 2015, 6:02pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/8 "2015-06-24T18:02:48Z")

</div>

I have this GET method:

```auto
  void SendEmailData(string email,string password){
    try{
        HttpMessageHandler LogInReq = new HttpMessageHandler();
        var createRequ = LogInReq.CreateRequest("GET","https://api.parse.com/1/users?where={\"email\":\""+email.ToLower()+"\"}&count=1&quot;); createRequ.SetHeader("Content-type", "application/json");
        createRequ.SetHeader("X-Parse-Application-Id","*APP ID");
        createRequ.SetHeader("X-Parse-REST-API-Key","REST API KEY*");
        createRequ.Done += GetEmailData;
        createRequ.Error += Error;
        createRequ.GetResponseContentString();
        createRequ.SetResponseType(HttpResponseType.String);
      createRequ.SendAsync();
    }catch(Exception e){
    }

```

}

This code in Fuse Preview works and in Android. But dont work in IOS…

In IOS if I remove from the url:

```auto
?where={\"email\":\""+email.ToLower()+"\"}&count=1");

```

Works, but with the complete url dont work!

---

<div class="post-metadata">

**Author:** ![kusma](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kusma/32/595_2.png) [@kusma](https://forums.fusetools.com/u/kusma)\
**Post date:** [June 26, 2015, 8:57am UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/9 "2015-06-26T08:57:36Z")

</div>

We have some fixes in this area that are pending, but not released yet. Sorry for this taking some time.

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 10, 2015, 3:44pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/10 "2015-07-10T15:44:29Z")

</div>

In the new version (v0.5.3127) still have the same error! Any news in this? I cant test my app in IOS because my HTTP request have this structure:

```auto
http://url.com?where={\"email\":\""+email.ToLower()+"\"}&count=1");  

```

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 13, 2015, 12:31pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/11 "2015-07-13T12:31:23Z")

</div>

Also in android I have a problem when the URL contain characters like “$” and “^”.

Nothing about this topic?

---

<div class="post-metadata">

**Author:** ![petterroea](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/petterroea/32/438_2.png) [@petterroea](https://forums.fusetools.com/u/petterroea)\
**Post date:** [July 14, 2015, 1:32pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/12 "2015-07-14T13:32:20Z")

</div>

Hey;

Do you get any errors when you use URL’s containing characters like $ and ^?

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 14, 2015, 1:49pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/13 "2015-07-14T13:49:25Z")

</div>

Yes, in Android. And in IOS when my URL contains variables likes this:

```auto
"http://myurl.com/where={\"VariableTitle\":\""+ MyVariable +"\"..."

```

---

<div class="post-metadata">

**Author:** ![petterroea](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/petterroea/32/438_2.png) [@petterroea](https://forums.fusetools.com/u/petterroea)\
**Post date:** [July 14, 2015, 1:55pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/14 "2015-07-14T13:55:16Z")

</div>

Could you post the errors you get, so the issue can be investigated? An isolated testcase would also be awesome.

---

<div class="post-metadata">

**Author:** ![petterroea](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/petterroea/32/438_2.png) [@petterroea](https://forums.fusetools.com/u/petterroea)\
**Post date:** [July 14, 2015, 2:05pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/15 "2015-07-14T14:05:04Z")

</div>

Also, remember to url encode the json you are trying to pass with `where` 🙂

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 14, 2015, 2:06pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/16 "2015-07-14T14:06:32Z")

</div>

I dont get any error in the debug. In IOS the HTTP request that contains this structure always trigger the

```auto
Myrequest.Error += Error;

```

But in Android or in my Mac works perfect.

In Android when the url containing characters like $ and ^ I cant see the json results…

This is an example of the error in IOS:

```auto
  void SendEmailData(string email,string password){
  try{
    HttpMessageHandler LogInReq = new HttpMessageHandler();
    var createRequ = LogInReq.CreateRequest("GET","https://api.parse.com/1/users?where={\"email\":\""+email.ToLower()+"\"}&count=1");  
    createRequ.SetHeader("Content-type", "application/json");
    createRequ.SetHeader("X-Parse-Application-Id"," *****APP ID****");
    createRequ.SetHeader("X-Parse-REST-API-Key"," ****REST API KEY*****");
    createRequ.Done += GetEmailData;
    createRequ.Error += Error;
    createRequ.GetResponseContentString();
    createRequ.SetResponseType(HttpResponseType.String);
    createRequ.SendAsync();
  }catch(Exception e){
  }
}

```

This code in Fuse Preview works and in Android. But dont work in IOS…

In IOS if I remove from the url:

```auto
?where={\"email\":\""+email.ToLower()+"\"}&count=1"); 

```

Works, but with the complete url dont work!

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [July 14, 2015, 3:44pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/17 "2015-07-14T15:44:31Z")

</div>

Ok, the search that didn’t work on android is fixed, the problem was that i was doing a request to a link with an space in a value, i changed the space with “%20” and now it works.

It was a search for users based on their full name, obviusly with a space between first and last name

The error in iOS is that the error function in “HttpMessageHandler.Error” is always triggered even when the http request it has succefully finished.

i think there is no url encode un Fuse or is not in the documentation, but i dont need it cos im encoding it manually, how is that? I’m adding all the parameters directly to the url of the request like this

```auto
https://api.parse.com/1/users?where={\"email\":\""+email.ToLower()+"\"}&count=1 

```

This error only happens with parse request with parameters, like the one i posted and only in iOS, this works on Android and CMake (and old preview)

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 17, 2015, 3:05pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/18 "2015-07-17T15:05:02Z")

</div>

Can anyone help us? I try replacing the ? to %3F and & to %26. But nothing! The request dont work…

How can I fix this in IOS?

Please!

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [July 17, 2015, 4:12pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/19 "2015-07-17T16:12:52Z")

</div>

Cristian : Thanks for reporting your issue. I’ve filed an internal ticket, and someone from the libs team will take a look at it Monday.

Thanks for your patience!

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [July 20, 2015, 5:56pm UTC](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082/20 "2015-07-20T17:56:31Z")

</div>

Thanks!

[Next page](https://forums.fusetools.com/t/httpmessagehandler-request-done-and-error/1082.md?page=2)
