Skip to content
This repository

Mono support (no working) ? #57

Open
timnels opened this Issue March 23, 2011 · 15 comments

3 participants

timnels Attila Kiskó mdrobnak
timnels

I can't seem to get a configuration file going under Mono. I keep getting exception with my Web.config / App.config. This works FINE under windows.

I read that is optional in the config file does anyone know why it is required in RedHat?
I created a simple test application and it does the same thing.

Please help...

------------------------ Exception ----------------
Unhandled Exception: System.Configuration.ConfigurationErrorsException: factory must be defined
at Enyim.Caching.Configuration.FactoryElement`1[Membase.Configuration.IMembasePerformanceMonitorFactory].CreateInstance () [0x00000] in :0
at Membase.Configuration.MembaseClientSection.Membase.Configuration.IMembaseClientConfiguration.CreatePerformanceMonitor () [0x00000] in :0
at Membase.MembaseClient..ctor (IMembaseClientConfiguration configuration, System.String bucketName, System.String bucketPassword) [0x00000] in :0
at Membase.MembaseClient..ctor () [0x00000] in :0
at Test.Main () [0x00000] in :0

----------------------- App.Config -----------------
<?xml version="1.0"?>












--------------------- Simple test program ------------
using Membase;
using Enyim.Caching.Memcached;
public class Test {
public static void Main() {
MembaseClient client = new MembaseClient("Default");
System.Console.WriteLine();
}
}

Attila Kiskó
Owner
enyim commented March 23, 2011

Good question.

This might be a difference in implementation between Mono and .NET. I'll look into it.

Meanwhile probably you could implement an empty performnce counter and register it.

(Or just uncomment the perf. counter loading part of the client...)

timnels
timnels

Any thoughts on where to go from here? I'd really like to use Membase instead of just Memcached.

Attila Kiskó
Owner
enyim commented April 05, 2011

it seems to be working if i remove the perf.counter section

timnels
Attila Kiskó
Owner
enyim commented April 05, 2011

if your config file has a section, it does not work. if you remove it, it works. i'm still debugging the mono source to find out what they did differently.

Attila Kiskó
Owner
enyim commented April 05, 2011

and you either need to use the default constructor (loads the app/web.config), or create a MembaceClientConfiguration object and pass it to the constructor (ignores the config, has no issues on mono).

mdrobnak

I have gotten past the above issue by commenting out the performance monitor related code in the Membase code (it all returns null).

Now, I have the following problem:

2011-04-24 21:27:18,613 [Threapool worker] INFO Membase.MembasePool - Received new configuration.
2011-04-24 21:27:18,613 [Threapool worker] INFO Membase.MembasePool - Config is empty, all nodes are down.
2011-04-24 21:27:18,613 [Threapool worker] DEBUG Membase.MessageStreamListener - Processing message:
2011-04-24 21:27:28,637 [Threapool worker] DEBUG Membase.MessageStreamListener - Looking for the first working node.
2011-04-24 21:27:28,657 [Threapool worker] ERROR Membase.BucketConfigListener - Error resolving streaming uri: http://10.9.11.168:8091/pools/default
System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer ---> System.InvalidCastException: Cannot cast from source type to destination type.
at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) [0x0000d] in /usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs:66
at System.Web.Script.Serialization.JavaScriptSerializer..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at Membase.ConfigHelper.DeserializeUriClusterInfo [0x00000] in :0
at Membase.ConfigHelper.GetClusterInfo (System.Net.WebClient client, System.Uri clusterUrl) [0x00000] in :0
at Membase.ConfigHelper.ResolveBucket (System.Net.WebClient client, System.Uri poolUri, System.String name) [0x00000] in :0
at Membase.BucketConfigListener.ResolveBucketUri (Membase.WebClientWithTimeout client, System.Uri root, System.String bucketName) [0x00000] in :0
2011-04-24 21:27:28,658 [Threapool worker] WARN Membase.MessageStreamListener - Could not resolve url http://10.9.11.168:8091/pools/default; trying the next in the list
2011-04-24 21:27:28,680 [Threapool worker] ERROR Membase.BucketConfigListener - Error resolving streaming uri: http://10.9.11.169:8091/pools/default
System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer ---> System.InvalidCastException: Cannot cast from source type to destination type.
at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) [0x0000d] in /usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs:66
at System.Web.Script.Serialization.JavaScriptSerializer..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at Membase.ConfigHelper.DeserializeUriClusterInfo [0x00000] in :0
at Membase.ConfigHelper.GetClusterInfo (System.Net.WebClient client, System.Uri clusterUrl) [0x00000] in :0
at Membase.ConfigHelper.ResolveBucket (System.Net.WebClient client, System.Uri poolUri, System.String name) [0x00000] in :0
at Membase.BucketConfigListener.ResolveBucketUri (Membase.WebClientWithTimeout client, System.Uri root, System.String bucketName) [0x00000] in :0
2011-04-24 21:27:28,681 [Threapool worker] WARN Membase.MessageStreamListener - Could not resolve url http://10.9.11.169:8091/pools/default; trying the next in the list
2011-04-24 21:27:28,681 [Threapool worker] WARN Membase.MessageStreamListener - Could not found a working node.
2011-04-24 21:27:28,681 [Threapool worker] WARN Membase.MessageStreamListener - All nodes are dead, sleeping for a while.
2011-04-24 21:27:28,681 [Threapool worker] INFO Membase.MembasePool - Received new configuration.
2011-04-24 21:27:28,681 [Threapool worker] INFO Membase.MembasePool - Config is empty, all nodes are down.
2011-04-24 21:27:28,681 [Threapool worker] DEBUG Membase.MessageStreamListener - Processing message:
2011-04-24 21:27:38,704 [Threapool worker] DEBUG Membase.MessageStreamListener - Looking for the first working node.
2011-04-24 21:27:38,729 [Threapool worker] ERROR Membase.BucketConfigListener - Error resolving streaming uri: http://10.9.11.168:8091/pools/default
System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer ---> System.InvalidCastException: Cannot cast from source type to destination type.
at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) [0x0000d] in /usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs:66
at System.Web.Script.Serialization.JavaScriptSerializer..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at Membase.ConfigHelper.DeserializeUriClusterInfo [0x00000] in :0
at Membase.ConfigHelper.GetClusterInfo (System.Net.WebClient client, System.Uri clusterUrl) [0x00000] in :0
at Membase.ConfigHelper.ResolveBucket (System.Net.WebClient client, System.Uri poolUri, System.String name) [0x00000] in :0
at Membase.BucketConfigListener.ResolveBucketUri (Membase.WebClientWithTimeout client, System.Uri root, System.String bucketName) [0x00000] in :0
2011-04-24 21:27:38,730 [Threapool worker] WARN Membase.MessageStreamListener - Could not resolve url http://10.9.11.168:8091/pools/default; trying the next in the list
2011-04-24 21:27:38,768 [Threapool worker] ERROR Membase.BucketConfigListener - Error resolving streaming uri: http://10.9.11.169:8091/pools/default
System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer ---> System.InvalidCastException: Cannot cast from source type to destination type.
at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) [0x0000d] in /usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs:66
at System.Web.Script.Serialization.JavaScriptSerializer..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at Membase.ConfigHelper.DeserializeUriClusterInfo [0x00000] in :0
at Membase.ConfigHelper.GetClusterInfo (System.Net.WebClient client, System.Uri clusterUrl) [0x00000] in :0
at Membase.ConfigHelper.ResolveBucket (System.Net.WebClient client, System.Uri poolUri, System.String name) [0x00000] in :0
at Membase.BucketConfigListener.ResolveBucketUri (Membase.WebClientWithTimeout client, System.Uri root, System.String bucketName) [0x00000] in :0
2011-04-24 21:27:38,769 [Threapool worker] WARN Membase.MessageStreamListener - Could not resolve url http://10.9.11.169:8091/pools/default; trying the next in the list
2011-04-24 21:27:38,769 [Threapool worker] WARN Membase.MessageStreamListener - Could not found a working node.
2011-04-24 21:27:38,769 [Threapool worker] WARN Membase.MessageStreamListener - All nodes are dead, sleeping for a while.

This also occurs when using the ConfigurationObject type of setup. The authentication is correct - I can see it making the REST call using tcpdump. It never connects to the Membase port (11121?) though.

Any suggestions? I really need to get this working on Mono. The caching part is the last issue to tackle.

Thanks.

-Matt

mdrobnak

As an update, I have the workaround as well:

Add this to the bottom of your web.config:

 <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions"
                              publicKeyToken="31bf3856ad364e35"
                              culture="neutral" />
            <bindingRedirect oldVersion="3.5.0.0"
                             newVersion="4.0.0.0"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>

as per:

https://bugzilla.novell.com/show_bug.cgi?id=664813

-Matt

timnels

Matt,
Are you saying your work around requires commenting out all the code AND changing web.config?
Thanks.

mdrobnak
timnels

Matt,
Pretty sure I tried the app parameters from web.config and I still had issue. Care to share some example code?
Thanks.
Tim

mdrobnak
public static class ClickCache
{

    public static MembaseClient Cache;


    static ClickCache()
    {
        Cache = new MembaseClient();
    }

And then in web.config:

  <configSections>
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
    <section name="membase" type="Membase.Configuration.MembaseClientSection, Membase" />
    <sectionGroup name="enyim.com">
      <section name="log" type="Enyim.Caching.Configuration.LoggerSection, Enyim.Caching" />
    </sectionGroup>
  </configSections>
  <enyim.com>
    <log factory="Enyim.Caching.Log4NetFactory, Enyim.Caching.Log4NetAdapter" />
  </enyim.com>
  <membase>
  <servers bucket="NMSClickCacheQ" bucketPassword="password" retryCount="2" retryTimeout="00:00:02">
    <!--
                Provide at least 2-3 urls from your cluster. 
                Usually you only need to change the host, except when connecting to older versions.
                Membase uses port 8091, while the NorthScale Memcached Server (1.0.3) uses 8080
            -->
    <add uri="http://192.168.2.202:8091/pools/default" />
    <add uri="http://192.168.2.200:8091/pools/default" />
  </servers>
  <!-- the client waits deadTmimeout time to reconnect to the pool when all the specified urls are down -->
  <socketPool connectionTimeout="00:00:10" deadTimeout="00:00:10" />
  </membase>

Leave the URLs where they are - /pools/default is right no matter what the bucket name is..

-Matt

mdrobnak

Mind you this is with the PerformanceFactory stuff disabled...

You're better off setting the URIs and stuff like this:

<appsettings>
    <add key="CACHE_SERVER_1" value="http://1.2.3.4:8090/pool/default/" />
    <add key="CACHE_SERVER_2" value="http://1.2.3.4:8090/pool/default/" />
    <add key="CACHE_NAME" value="cachename" />
    <add key="CACHE_PASS" value="pass" />
</appsettings>

In your cs file:

public static class theCache
{

public static MembaseClient Cache;
public static MembaseClientConfiguration CacheConfig;

static theCache()
{
    CacheConfig = new MembaseClientConfiguration();
    Uri CacheServer1 = new Uri(ConfigurationManager.AppSettings["CACHE_SERVER_1"]);
    Uri CacheServer2 = new Uri(ConfigurationManager.AppSettings["CACHE_SERVER_2"]);
    CacheConfig.Urls.Add(CacheServer1);
    CacheConfig.Urls.Add(CacheServer2);
    CacheConfig.Bucket=ConfigurationManager.AppSettings["CACHE_NAME"];
    CacheConfig.BucketPassword=ConfigurationManager.AppSettings["CACHE_PASS"];
    Cache = new MembaseClient(CacheConfig);
}

Something to that effect.

-Matt
mdrobnak

Ugh. The web.config stuff went away:

    <add key="CACHE_SERVER_1" value="http://1.2.3.4:8090/pool/default/" />
    <add key="CACHE_SERVER_2" value="http://1.2.3.4:8090/pool/default/" />
    <add key="CACHE_NAME" value="nmsclickcache" />
    <add key="CACHE_PASS" value="nms1" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.