I am trying to change the geographical locations of a currently running filtered stream. I have read another thread on the forum on how to do this..
```
public static _filteredStream = Stream.CreateFilteredStream();
public static void ChangeStreamBounds(BoundingBoxPoint points)
{
_filteredStream.StopStream(); // stop the stream before changing any params
_filteredStream.ClearLocations();
var sw = new Coordinates(points.SouthWestLongitude, points.SouthWestLatitude);
var ne = new Coordinates(points.NorthEastLongitude, points.NorthEastLatitude);
_filteredStream.AddLocation(sw,ne);
_filteredStream.StartStreamMatchingAllConditions();// restart matching all conditions
}
```
Unfortunately when I step through this method, I reach the end without any problems and I step onto the next statement and then I encounter a WebException. This is caught by my WebExceptionReceived lambda:
```
ExceptionHandler.WebExceptionReceived += (sender, args) =>
{
var exc = (ITwitterException)args.Value;
Debug.WriteLine("---------------------------------------------");
Debug.WriteLine("Message:" + exc.WebException.Message);
Debug.WriteLine("HResult:" + exc.WebException.HResult);
Debug.WriteLine("StackTrace:" + exc.WebException.StackTrace);
Debug.WriteLine("Inner:" + exc.WebException.InnerException);
Debug.WriteLine("Target Site:" + exc.WebException.TargetSite);
Debug.WriteLine("Response:" + exc.WebException.Response);
Debug.WriteLine("Response Status:" + exc.WebException.Status);
Debug.WriteLine("Twitter Desc:" + exc.TwitterDescription);
Debug.WriteLine("Request URL:" + exc.URL);
Debug.WriteLine("---------------------------------------------");
};
```
Which produces this output:
```
Message:The request was aborted: The request was canceled.
HResult:-2146233079
StackTrace: at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Tweetinvi.Streams.Helpers.StreamResultGenerator.<StartStreamAsync>d__7.MoveNext()
Inner:
Target Site:Void ThrowForNonSuccess(System.Threading.Tasks.Task)
Response:
Response Status:RequestCanceled
Twitter Desc:
Request URL:
```
Other threads on the web for the error message "The request was aborted: The request was canceled" tend to suggest that this is to do with the HttpWebRequest class - This SO thread (http://stackoverflow.com/questions/2459241/httpwebrequest-the-request-was-aborted-the-request-was-canceled) suggests a fix is to change the webRequest1.KeepAlive option to false. Considering the HttpWebRequest functionality is too far under the hood of the TweetInvi library, I was wondering how I can change this opt (if this is the root cause of the problem).
Am I doing something wrong here?
n.b I am using the stream in a thread as per your advice in this thread (https://tweetinvi.codeplex.com/workitem/2266)
```
public static _filteredStream = Stream.CreateFilteredStream();
public static void ChangeStreamBounds(BoundingBoxPoint points)
{
_filteredStream.StopStream(); // stop the stream before changing any params
_filteredStream.ClearLocations();
var sw = new Coordinates(points.SouthWestLongitude, points.SouthWestLatitude);
var ne = new Coordinates(points.NorthEastLongitude, points.NorthEastLatitude);
_filteredStream.AddLocation(sw,ne);
_filteredStream.StartStreamMatchingAllConditions();// restart matching all conditions
}
```
Unfortunately when I step through this method, I reach the end without any problems and I step onto the next statement and then I encounter a WebException. This is caught by my WebExceptionReceived lambda:
```
ExceptionHandler.WebExceptionReceived += (sender, args) =>
{
var exc = (ITwitterException)args.Value;
Debug.WriteLine("---------------------------------------------");
Debug.WriteLine("Message:" + exc.WebException.Message);
Debug.WriteLine("HResult:" + exc.WebException.HResult);
Debug.WriteLine("StackTrace:" + exc.WebException.StackTrace);
Debug.WriteLine("Inner:" + exc.WebException.InnerException);
Debug.WriteLine("Target Site:" + exc.WebException.TargetSite);
Debug.WriteLine("Response:" + exc.WebException.Response);
Debug.WriteLine("Response Status:" + exc.WebException.Status);
Debug.WriteLine("Twitter Desc:" + exc.TwitterDescription);
Debug.WriteLine("Request URL:" + exc.URL);
Debug.WriteLine("---------------------------------------------");
};
```
Which produces this output:
```
Message:The request was aborted: The request was canceled.
HResult:-2146233079
StackTrace: at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Tweetinvi.Streams.Helpers.StreamResultGenerator.<StartStreamAsync>d__7.MoveNext()
Inner:
Target Site:Void ThrowForNonSuccess(System.Threading.Tasks.Task)
Response:
Response Status:RequestCanceled
Twitter Desc:
Request URL:
```
Other threads on the web for the error message "The request was aborted: The request was canceled" tend to suggest that this is to do with the HttpWebRequest class - This SO thread (http://stackoverflow.com/questions/2459241/httpwebrequest-the-request-was-aborted-the-request-was-canceled) suggests a fix is to change the webRequest1.KeepAlive option to false. Considering the HttpWebRequest functionality is too far under the hood of the TweetInvi library, I was wondering how I can change this opt (if this is the root cause of the problem).
Am I doing something wrong here?
n.b I am using the stream in a thread as per your advice in this thread (https://tweetinvi.codeplex.com/workitem/2266)