samlegus / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Documents API doesn't work with WebRequest.DefaultProxy #544

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Connect to DocumentsRequest thru a proxy (http://proxyconf:80 or 
http://proxyconf) script and load Documents.

What is the expected output? 
A list of googleNotes retrieved from Google Documents folder "Notes".

What do you see instead?
The following error: The underlying connection was closed: An unexpected error 
occurred on a send

What version of the product are you using? 
Google Data API 1.9 released in Sep 2011
On what operating system?

Here is the code sample I am using, it is working fine without Proxy (i.e. with 
WebRequest.DefaultWebProxy), but it doesn't work with proxyconf script. The 
ContactsRequest works fine with the proxyconf script.

RequestSettings rs = new RequestSettings("GoogleContactSyncMod", username, 
password); 
DocumentsRequest documentsRequest = new DocumentsRequest(rs);
System.Net.WebProxy myProxy = new System.Net.WebProxy("proxyconf", "80");
myProxy.BypassProxyOnLocal = false;
Collection<Document> googleNotes = new Collection<Document>();
Document googleNotesFolder = null;
DocumentQuery query = new DocumentQuery(_documentsRequest.BaseUri);
query.Categories.Add(new QueryCategory(new AtomCategory("folder")));
query.Title = "Notes"
Feed<Document> feed = _documentsRequest.Get<Document>(query);

if (feed != null)
{
 foreach (Document a in feed.Entries)
 {
     googleNotesFolder = a;
     break;
 }                    
}

if (googleNotesFolder == null)
{
  googleNotesFolder = new Document();
  googleNotesFolder.Type = Document.DocumentType.Folder;
  googleNotesFolder.Title = query.Title;
  Uri feedUri = new Uri(documentsRequest.BaseUri);
  Document googleNotesFolder = documentsRequest.Insert(feedUri, googleNotesFolder);
}

query = new DocumentQuery(googleNotesFolder.DocumentEntry.Content.AbsoluteUri);
query.Categories.Add(new QueryCategory(new AtomCategory("document")));
query.NumberToRetrieve = 256;
query.StartIndex = 0;                

feed = _documentsRequest.Get<Document>(query);

while (feed != null)
{
    foreach (Document a in feed.Entries)
    {
       googleNotes.Add(a);
       if (id != null && id.Equals(a.DocumentEntry.Id))
            ret = a;
     }
     query.StartIndex += query.NumberToRetrieve;
     feed = documentsRequest.Get<Document>(feed, feedRequestType.Next);
}

It is also not working with the following app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">            
      <proxy usesystemdefault="True" scriptLocation="http://proxyconf"/>

    </defaultProxy>
  </system.net>
</configuration>

Original issue reported on code.google.com by Saller....@gmail.com on 5 Oct 2011 at 5:49

GoogleCodeExporter commented 9 years ago
Can you capture the HTTP traffic with Fiddler and share it with us?
Please do that twice, once without proxy and another one with your proxy setup.
Thanks

Original comment by ccherub...@google.com on 5 Oct 2011 at 4:17

GoogleCodeExporter commented 9 years ago
I have installed Fiddler now, but how can I add my C# program 
(GoContactSyncMod.exe) now to the processes? I only get IE sessions displayed, 
even when I select the process GoContactSync to trace, I get no Web sessions 
displayed. If you want, you can try it on your own, just download the 
GoContactSync sources from http://sourceforge.net/projects/googlesyncmod/
Or you guide me how I can trace the traffic from there.

Original comment by Saller....@gmail.com on 5 Oct 2011 at 4:45

GoogleCodeExporter commented 9 years ago
You should probably enable the decryption of HTTPS-protected traffic:

http://www.fiddler2.com/Fiddler/help/httpsdecryption.asp

Is GoContactSyncMod a tool you wrote? If not, you should ask the project owners 
for support, I see the Beta version has some changes related to proxy 
management:

http://sourceforge.net/projects/googlesyncmod/files/Betas/

Original comment by ccherub...@google.com on 5 Oct 2011 at 4:51

GoogleCodeExporter commented 9 years ago
I enabled the HTTPS protected traffic, but it didn't work also, but after 
restarting Fiddler2 I was able to catch some traffic from GoContactSync, see 
attached file (without proxy). Unfortunatelly I couldn't find much details in 
the trace log (only 2 connects).

Please note, that GoContactSyncMod is a tool I wrote (together with some other 
guys, but I am the main developer and the BETA was a trial to improve the Proxy 
Settings with ContactsRequest, this week we wanted to rollout the new version 
with improved proxy, it worked fine with ContactsRequest, but it didn't work 
with DocumentsRequest. After testing the old workaround approach to use 
System.net section in App.config, waht already worked before the BETA for 
ContactsRequest, we found out, that this workaround also not works for 
DocumentsRequest (I never tested it with proxy, because on my development PC I 
don't have a proxy and it worked fine, but on my deployment PC I have a proxy 
script and there it didn't work).

Original comment by Saller....@gmail.com on 5 Oct 2011 at 6:53

Attachments:

GoogleCodeExporter commented 9 years ago
It is something like a miracle, but I tested it today afternoon and now it 
worked. So I think you can close this issue, I guess it is related with our 
working environment, sometimes it is working, sometimes not, but it is not a 
Google Data API issue.

-- CLOSED ---

Original comment by Saller....@gmail.com on 25 Oct 2011 at 3:26

GoogleCodeExporter commented 9 years ago

Original comment by ccherub...@google.com on 25 Oct 2011 at 3:52