Fix: Disable HTTP KeepAlive
To improve support for proxy servers which do not support this optimisation. See: http://discoict.com.au/forum/support/2013/2/connection-issues,-lwt,-updates-etc.aspx
This commit is contained in:
@@ -1,88 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Web.Models.InitialConfig
|
||||
{
|
||||
public class CompleteModel
|
||||
{
|
||||
public Tuple<IPHostEntry, Exception> DiscoDnsTestResult { get; set; }
|
||||
public Exception RegistryDatabaseResult { get; set; }
|
||||
public Exception DiscoIctComAuWebResult { get; set; }
|
||||
|
||||
public bool LaunchAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RegistryDatabaseResult == null);
|
||||
}
|
||||
}
|
||||
|
||||
public void PerformTests()
|
||||
{
|
||||
|
||||
#region DNS for 'Disco'
|
||||
try
|
||||
{
|
||||
// Try and Resolve 'disco'
|
||||
DiscoDnsTestResult = new Tuple<IPHostEntry, Exception>(Dns.GetHostEntry("disco"), null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoDnsTestResult = new Tuple<IPHostEntry, Exception>(null, ex);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Write Database to Registry
|
||||
try
|
||||
{
|
||||
// Make Connection String Persistent
|
||||
Disco.Data.Repository.DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString(
|
||||
Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString, true);
|
||||
RegistryDatabaseResult = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RegistryDatabaseResult = ex;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Communicate with http://discoict.com.au/
|
||||
try
|
||||
{
|
||||
Dns.GetHostEntry("discoict.com.au");
|
||||
try
|
||||
{
|
||||
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://discoict.com.au/");
|
||||
wReq.Method = WebRequestMethods.Http.Get;
|
||||
wReq.UserAgent = string.Format("Disco/{0} (Initial Config; Org: {1})", DiscoApplication.Version, DiscoApplication.OrganisationName);
|
||||
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
|
||||
{
|
||||
if (wRes.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
DiscoIctComAuWebResult = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscoIctComAuWebResult = new Exception(string.Format("Server returned response: [{0}] {1}", wRes.StatusCode, wRes.StatusDescription));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoIctComAuWebResult = new WebException("DNS Resolved the host 'discoict.com.au' but could not establish a connection.", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoIctComAuWebResult = new Exception("Could not resolve the name 'discoict.com.au'", ex);
|
||||
throw;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Web.Models.InitialConfig
|
||||
{
|
||||
public class CompleteModel
|
||||
{
|
||||
public Tuple<IPHostEntry, Exception> DiscoDnsTestResult { get; set; }
|
||||
public Exception RegistryDatabaseResult { get; set; }
|
||||
public Exception DiscoIctComAuWebResult { get; set; }
|
||||
|
||||
public bool LaunchAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RegistryDatabaseResult == null);
|
||||
}
|
||||
}
|
||||
|
||||
public void PerformTests()
|
||||
{
|
||||
|
||||
#region DNS for 'Disco'
|
||||
try
|
||||
{
|
||||
// Try and Resolve 'disco'
|
||||
DiscoDnsTestResult = new Tuple<IPHostEntry, Exception>(Dns.GetHostEntry("disco"), null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoDnsTestResult = new Tuple<IPHostEntry, Exception>(null, ex);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Write Database to Registry
|
||||
try
|
||||
{
|
||||
// Make Connection String Persistent
|
||||
Disco.Data.Repository.DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString(
|
||||
Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString, true);
|
||||
RegistryDatabaseResult = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RegistryDatabaseResult = ex;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Communicate with http://discoict.com.au/
|
||||
try
|
||||
{
|
||||
Dns.GetHostEntry("discoict.com.au");
|
||||
try
|
||||
{
|
||||
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://discoict.com.au/");
|
||||
// Added: 2013-02-08 G#
|
||||
// Fix for Proxy Servers which dont support KeepAlive
|
||||
wReq.KeepAlive = false;
|
||||
// End Added: 2013-02-08 G#
|
||||
wReq.Method = WebRequestMethods.Http.Get;
|
||||
wReq.UserAgent = string.Format("Disco/{0} (Initial Config; Org: {1})", DiscoApplication.Version, DiscoApplication.OrganisationName);
|
||||
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
|
||||
{
|
||||
if (wRes.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
DiscoIctComAuWebResult = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscoIctComAuWebResult = new Exception(string.Format("Server returned response: [{0}] {1}", wRes.StatusCode, wRes.StatusDescription));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoIctComAuWebResult = new WebException("DNS Resolved the host 'discoict.com.au' but could not establish a connection.", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscoIctComAuWebResult = new Exception("Could not resolve the name 'discoict.com.au'", ex);
|
||||
throw;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Disco.Web.Models.InitialConfig
|
||||
{
|
||||
public class WelcomeModel
|
||||
{
|
||||
[Required(ErrorMessage="The Organisation Name is required.")]
|
||||
public string OrganisationName { get; set; }
|
||||
|
||||
|
||||
private static string _OrganisationNameCache;
|
||||
public bool AutodetectOrganisation()
|
||||
{
|
||||
if (_OrganisationNameCache != null)
|
||||
{
|
||||
this.OrganisationName = _OrganisationNameCache;
|
||||
return true;
|
||||
}
|
||||
|
||||
// DnsQuery for broadband.doe.wan
|
||||
IPHostEntry doeWanDnsEntry;
|
||||
try
|
||||
{
|
||||
doeWanDnsEntry = Dns.GetHostEntry("broadband.doe.wan");
|
||||
}
|
||||
catch (Exception)
|
||||
{ return false; } // Fail on error
|
||||
|
||||
// Try using IPSearch feature
|
||||
XDocument doeWanIPSearchResult = TryDownloadDoeIPSearch(true);
|
||||
if (doeWanIPSearchResult == null)
|
||||
doeWanIPSearchResult = TryDownloadDoeIPSearch(false);
|
||||
|
||||
if (doeWanIPSearchResult == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var siteName = doeWanIPSearchResult.Element("resultset").Element("site").Element("name").Value.ToLower();
|
||||
this.OrganisationName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(siteName);
|
||||
_OrganisationNameCache = this.OrganisationName;
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{ return false; } // Fail on error
|
||||
}
|
||||
private XDocument TryDownloadDoeIPSearch(bool useProxy)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://broadband.doe.wan/ipsearch/showresult.php");
|
||||
if (!useProxy)
|
||||
wReq.Proxy = new WebProxy(); // Empty Proxy Config
|
||||
wReq.Method = WebRequestMethods.Http.Post;
|
||||
wReq.ContentType = "application/x-www-form-urlencoded";
|
||||
wReq.UserAgent = string.Format("Disco/{0}", DiscoApplication.Version);
|
||||
using (var wrStream = wReq.GetRequestStream())
|
||||
{
|
||||
using (var wrStreamWriter = new StreamWriter(wrStream))
|
||||
{
|
||||
wrStreamWriter.Write("mode=whoami");
|
||||
}
|
||||
}
|
||||
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
|
||||
{
|
||||
if (wRes.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
using (var wResStream = wRes.GetResponseStream())
|
||||
{
|
||||
return XDocument.Load(wResStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{ return null; } // Fail on error
|
||||
}
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Disco.Web.Models.InitialConfig
|
||||
{
|
||||
public class WelcomeModel
|
||||
{
|
||||
[Required(ErrorMessage="The Organisation Name is required.")]
|
||||
public string OrganisationName { get; set; }
|
||||
|
||||
|
||||
private static string _OrganisationNameCache;
|
||||
public bool AutodetectOrganisation()
|
||||
{
|
||||
if (_OrganisationNameCache != null)
|
||||
{
|
||||
this.OrganisationName = _OrganisationNameCache;
|
||||
return true;
|
||||
}
|
||||
|
||||
// DnsQuery for broadband.doe.wan
|
||||
IPHostEntry doeWanDnsEntry;
|
||||
try
|
||||
{
|
||||
doeWanDnsEntry = Dns.GetHostEntry("broadband.doe.wan");
|
||||
}
|
||||
catch (Exception)
|
||||
{ return false; } // Fail on error
|
||||
|
||||
// Try using IPSearch feature
|
||||
XDocument doeWanIPSearchResult = TryDownloadDoeIPSearch(true);
|
||||
if (doeWanIPSearchResult == null)
|
||||
doeWanIPSearchResult = TryDownloadDoeIPSearch(false);
|
||||
|
||||
if (doeWanIPSearchResult == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var siteName = doeWanIPSearchResult.Element("resultset").Element("site").Element("name").Value.ToLower();
|
||||
this.OrganisationName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(siteName);
|
||||
_OrganisationNameCache = this.OrganisationName;
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{ return false; } // Fail on error
|
||||
}
|
||||
private XDocument TryDownloadDoeIPSearch(bool useProxy)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://broadband.doe.wan/ipsearch/showresult.php");
|
||||
// Added: 2013-02-08 G#
|
||||
// Fix for Proxy Servers which dont support KeepAlive
|
||||
wReq.KeepAlive = false;
|
||||
// End Added: 2013-02-08 G#
|
||||
if (!useProxy)
|
||||
wReq.Proxy = new WebProxy(); // Empty Proxy Config
|
||||
wReq.Method = WebRequestMethods.Http.Post;
|
||||
wReq.ContentType = "application/x-www-form-urlencoded";
|
||||
wReq.UserAgent = string.Format("Disco/{0}", DiscoApplication.Version);
|
||||
using (var wrStream = wReq.GetRequestStream())
|
||||
{
|
||||
using (var wrStreamWriter = new StreamWriter(wrStream))
|
||||
{
|
||||
wrStreamWriter.Write("mode=whoami");
|
||||
}
|
||||
}
|
||||
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
|
||||
{
|
||||
if (wRes.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
using (var wResStream = wRes.GetResponseStream())
|
||||
{
|
||||
return XDocument.Load(wResStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{ return null; } // Fail on error
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user