mail-archives/mono-osx/2011-February/004053.html

150 строки
5.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-osx] FtpWebRequest &quot;Not connected&quot;
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20FtpWebRequest%20%22Not%20connected%22&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="004028.html">
<LINK REL="Next" HREF="004074.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-osx] FtpWebRequest &quot;Not connected&quot;</H1>
<B>chromex</B>
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20FtpWebRequest%20%22Not%20connected%22&In-Reply-To="
TITLE="[Mono-osx] FtpWebRequest &quot;Not connected&quot;">loren.hoffman at gmail.com
</A><BR>
<I>Tue Feb 15 17:58:56 EST 2011</I>
<P><UL>
<LI>Previous message: <A HREF="004028.html">[Mono-osx] CoreMidi Design
</A></li>
<LI>Next message: <A HREF="004074.html">[Mono-osx] FtpWebRequest &quot;Not connected&quot;
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4053">[ date ]</a>
<a href="thread.html#4053">[ thread ]</a>
<a href="subject.html#4053">[ subject ]</a>
<a href="author.html#4053">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
Hello,
I am porting a device management application from Windows to OSX and am
having problems with the FtpWebRequest system. I distilled an example of the
issue down to the code sample below. When run in OSX an exception is thrown
stating &quot;Not connected&quot;. This is odd because if I put in the wrong
credentials then it gives the error: &quot;Server returned an error: 530 Login
incorrect&quot; which implies that it the &quot;Not connected&quot; error is happening
after a successful authentication. Besides this example being taken from
code that works in Windows it also correlates with all examples I have found
regarding FtpWebRequest. I have even checked that the final FtpWebRequest
fields match in Visual Studio and in Monodevelop right before the
GetResponse method is called; all do except for the Proxy property which
appears to be implemented slightly differently. Finally, I tried running the
code against multiple ftp servers including the target device and the built
in OSX ftp server, all with the same results.
It is possible I have a simple issue I am overlooking or there is some
aspect of it that requires extra care in OSX. If anyone has any input on
this or can confirm the issue on other systems that would help a lot. If any
other information is needed outside what I have already provided please let
me know.
Cheers,
- Loren
/////
// Example
using System;
using System.Net;
using System.IO;
namespace TestFTP
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine (&quot;Starting test...&quot;);
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(new
Uri(&quot;<A HREF="ftp://192.168.10.117/&quot;">ftp://192.168.10.117/&quot;</A>));
req.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
req.UseBinary = false;
req.KeepAlive = false;
req.UsePassive = false;
req.Credentials = new NetworkCredential(&quot;admin&quot;, &quot;admin&quot;);
try
{
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
Console.WriteLine(reader.ReadToEnd());
reader.Close();
}
catch(Exception e)
{
Console.WriteLine(&quot;Error: &quot;);
Console.WriteLine(e.Message);
}
}
}
}
/////
// Run Output
cd &quot;/Users/chromex/Projects/TestFTP/TestFTP/bin/Debug&quot;;
PKG_CONFIG_PATH=&quot;/Applications/MonoDevelop.app/Contents/MacOS/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/2.6.7/share/pkgconfig:/Library/Frameworks/Mono.framework/Versions/2.6.7/lib/pkgconfig&quot;
PKG_CONFIG_LIBDIR=&quot;&quot;
PATH=&quot;/Library/Frameworks/Mono.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin&quot;
/Library/Frameworks/Mono.framework/Versions/2.6.7/bin/mono --debug
&quot;/Users/chromex/Projects/TestFTP/TestFTP/bin/Debug/TestFTP.exe&quot; ; echo; read
-p 'Press any key to continue...' -n1; exit
Loren-Hoffmans-MacBook-Pro:~ chromex$ cd
&quot;/Users/chromex/Projects/TestFTP/TestFTP/bin/Debug&quot;;
PKG_CONFIG_PATH=&quot;/Applications/MonoDevelop.app/Contents/MacOS/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/2.6.7/share/pkgconfig:/Library/Frameworks/Mono.framework/Versions/2.6.7/lib/pkgconfig&quot;
PKG_CONFIG_LIBDIR=&quot;&quot;
PATH=&quot;/Library/Frameworks/Mono.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin&quot;
/Library/Frameworks/Mono.framework/Versions/2.6.7/bin/mono --debug
&quot;/Users/chromex/Projects/TestFTP/TestFTP/bin/Debug/TestFTP.exe&quot; ; echo; read
-p 'Press any key to continue...' -n1; exit
Starting test...
Error:
Not connected
--
View this message in context: <A HREF="http://mono.1490590.n4.nabble.com/FtpWebRequest-Not-connected-tp3307834p3307834.html">http://mono.1490590.n4.nabble.com/FtpWebRequest-Not-connected-tp3307834p3307834.html</A>
Sent from the Mono - OSX mailing list archive at Nabble.com.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="004028.html">[Mono-osx] CoreMidi Design
</A></li>
<LI>Next message: <A HREF="004074.html">[Mono-osx] FtpWebRequest &quot;Not connected&quot;
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4053">[ date ]</a>
<a href="thread.html#4053">[ thread ]</a>
<a href="subject.html#4053">[ subject ]</a>
<a href="author.html#4053">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
mailing list</a><br>
</body></html>