Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Visit the Wiki  |  Find us on: Twitter Facebook Google+ LinkedIn

Discussion Forums

The online community for users of Map Suite GIS components

MapSuite 6.0 timeout error
Last Post 08-15-2012 12:33 AM by Edgar. 53 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 2 of 3 << < 123 > >>
Author Messages Resolved
BenUser is Offline
MVP
MVP
Posts:1759
Avatar

--
07-23-2012 08:28 AM
Allen,

Yes, the solution is based on your specific scenario, but anyway close the connection after done with the layer would be helpful to reduce the connection number. Let us know if you find anything new and need help from us.

Ben

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

BenUser is Offline
MVP
MVP
Posts:1759
Avatar

--
07-23-2012 08:28 AM
Allen,

Yes, the solution is based on your specific scenario, but anyway close the connection after done with the layer would be helpful to reduce the connection number. Let us know if you find anything new and need help from us.

Ben

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
07-23-2012 11:23 AM
Ben,

I just tried the code to close the layers when I'm done. Unfortunately, the SQL layers think they're closed (that's what their status is in the debugger) but when I look at the connections in SQL Server it appears not to have gotten the message: there are still 50+ connections open even after I've iterated through all of the layers in the overlay and closed them. Seems to me that there's still something wrong here.

Allen
JohnUser is Offline
Level 2
Level 2
Posts:43
Avatar

--
07-24-2012 08:33 AM
So how do we get a resolution to actually close the connections? Is this something MapSuite needs to correct to properly close the connection?

-John
BenUser is Offline
MVP
MVP
Posts:1759
Avatar

--
07-25-2012 01:04 AM

Allen and John, 

The connection can be closed succesfully in my test. I tried the following code and the connection count on the SQL Server side is one after executing it. 


MsSql2008FeatureLayer[] layers = new MsSql2008FeatureLayer[100];
string conn = "Data Source=192.168.0.212;Initial Catalog=InternalDB;User ID=sa;Password=password";
for (int i = 0; i < 100; i++)
{
    layers[i] = new MsSql2008FeatureLayer(conn, "states", "recid");
    layers[i].Open();
    layers[i].ExecuteNonQuery("select * from states");
    layers[i].Close();
}

So can you create a sample to recreate your issue? And what version are you using in your test?

Ben

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
07-27-2012 10:46 AM

Ben,

Here's the code I'm trying...I load the same layer 50 times and then wait for a button to be clicked to go through and close all the layers.  This allows me to look in Management Studio and see what's going on.

namespace SQL_Connections

{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.Meter;
            RectangleShape extent = null;
 
            LayerOverlay overlay = new LayerOverlay();
 
            for (int ctr = 0; ctr < 50; ctr++)
            {
                string connString = @"Data Source=.\IRON_COMPASS; Initial Catalog=osx3; User Id=***** Password=*****";
                MsSql2008FeatureLayer sqlLayer = new MsSql2008FeatureLayer(connString, "*****", "*****", 3395);
                sqlLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway1;
                sqlLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County1;
                sqlLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
                if (ctr == 0)
                {
                    sqlLayer.Open();
                    extent = sqlLayer.GetBoundingBox();
                }
 
                sqlLayer.Name = "sqlLayer" + ctr;
                overlay.Layers.Add("sqlLayer" + ctr, sqlLayer);
            }
 
            winformsMap1.Overlays.Add("Overlay", overlay);
            winformsMap1.CurrentExtent = extent;
            winformsMap1.Refresh();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            string message = "";
 
            LayerOverlay overlay = (LayerOverlay)winformsMap1.Overlays["Overlay"];
            foreach (Layer layer in overlay.Layers)
            {
                if (layer.IsOpen)
                {
                    layer.Close();
                    message += "Layer: " + layer.Name + " - IsOpen = " + layer.IsOpen + "\n";
                }
 
            }
            MessageBox.Show(message);
        }
    }
}

After the initial redraw, the two screen captures below show what I see...ID 52 through 102 are all the login used in the above code, although for some reason ID 53 is never used.  I had to block out the login information which is confidential.

---a whole bunch more in between--

This makes sense since I'm loading 50 SQL layers.  After I click on the button the SQL layers are telling me they're all closed, which may be true...

 

But in Management Studio IDs 52 through 102 are still there and never go away.

Allen

 

AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
07-27-2012 11:05 AM
Ooops...almost forgot. I'm using the original release, 6.0.0.0. Earlier I asked if there was a reason to upgrade to a newer build and I take the lack of response as a "no". I don't have the time or desire to update to the latest daily build "just in case" it might fix a problem, but if it's documented that a specific newer daily build will fix a problem we've encounted, of course, I will update our projects. But thus far we're being told this was a "peformance enhancement" and not a "bug" that will be fixed, so I don't have any reason to update to a newer build.

I hope everyone has a great weekend!
Allen
EdgarUser is Offline
MVP
MVP
Posts:715
Avatar

--
07-29-2012 10:11 PM

Allen,

I test your code and find that there are 50 connections remains, the reason is that once the layer has been opened with a connection string, sql server will allocate a connection pool for it, and if another layer with the same string is opened, sql server will check the first connection’s status, if it is closed, the cached connection pool will be allocated for the second connection, otherwise, the second connection will be allocated with a new connection pool with the same string. So we suggest you to override all the method you need which may execute a query, and close it after using it. E.g.


class MyMsSql2008FeatureLayer : MsSql2008FeatureLayer
    {
        public MyMsSql2008FeatureLayer()
            : this(string.Empty, string.Empty, string.Empty, 0)
        { }

        public MyMsSql2008FeatureLayer(string connection, string tableName, string featureIdColumn)
            : this(connection, tableName, featureIdColumn, 0)
        { }

        public MyMsSql2008FeatureLayer(string connection, string tableName, string featureIdColumn, int srid)
        {
            this.FeatureSource = new MyMsSql2008FeatureSource(connection, tableName, featureIdColumn, srid);
        }

        protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
        {
            this.Open();
            base.DrawCore(canvas, labelsInAllLayers);
            this.Close();
        }
    }

    class MyMsSql2008FeatureSource : MsSql2008FeatureSource
    {
        public MyMsSql2008FeatureSource()
            : this(string.Empty, string.Empty, string.Empty, 0)
        { }

        public MyMsSql2008FeatureSource(string connection, string tableName, string featureIdColumn)
            : this(connection, tableName, featureIdColumn, 0)
        { }

        public MyMsSql2008FeatureSource(string connection, string tableName, string featureIdColumn, int srid)
            : base(connection, tableName, featureIdColumn, srid)
        { }

        protected override RectangleShape GetBoundingBoxCore()
        {
            this.Open();
            RectangleShape boundingBox = base.GetBoundingBoxCore();
            this.Close();
            return boundingBox;
        }
    }


MyMsSql2008FeatureLayer sqlLayer = new MyMsSql2008FeatureLayer(connString, "*****", "*****", 3395);

After replacing your code, the number of connections falls to 1. Hope this will help you.

Thanks,

Edgar
 

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

DavidUser is Offline
MVP
MVP
Posts:1534
Avatar

--
07-30-2012 02:29 AM
Allen,

I'm sorry for all of the confusion. I have been watching these posts and am working with the developers to get a solution for this. This is a strange one because there are two different people related to this and one swears that we used to close the connection on every request and that we changed this based on a ticket or older post and something because of performance issues while the other guy has been researching and testing this and is saying we should make the change. What I have decided to do is to have the first guy do some research on why we made the change and while that is going we are going to change the code to automatically close the connection after each query. While I think it is good that Edgar gave you a work around I think we can deliver a better solution without inheritances later this week.

David
- Need sample code? Check out the Map Suite Code Community at http://code.thinkgeo.com
DavidUser is Offline
MVP
MVP
Posts:1534
Avatar

--
08-01-2012 12:02 AM
Allen,

We have made some changes in the latest public release and we now by default auto close the connection. If you want to keep the connection open as some people want for performance you can change the SqlConnectionMode property on the featuresource to KeepOpen. We also added an additional set of constructors to control this behavior and also properties on the layer and feature source.

David

The changes has been made in development branch, Here is the API change list

MapSuiteCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null

namespace ThinkGeo.MapSuite.Core {
[SerializableAttribute]
public class MsSql2008FeatureLayer : FeatureLayer {
public MsSql2008FeatureLayer(String connectionString, String tableName, String featureIdColumn, SqlConnectionMode sqlConnectionMode);
public MsSql2008FeatureLayer(String connectionString, String tableName, String featureIdColumn, Int32 srid, SqlConnectionMode sqlConnectionMode);

public SqlConnectionMode SqlConnectionMode { get; set; }
}

[SerializableAttribute]
public class MsSql2008FeatureSource : FeatureSource {
public MsSql2008FeatureSource(String connectionString, String tableName, String featureIdColumn, SqlConnectionMode sqlConnectionMode);
public MsSql2008FeatureSource(String connectionString, String tableName, String featureIdColumn, Int32 srid, SqlConnectionMode sqlConnectionMode);

public SqlConnectionMode SqlConnectionMode { get; set; }
}

[SerializableAttribute]
public enum SqlConnectionMode {
Default,
AutoClose,
KeepOpen
}
}
- Need sample code? Check out the Map Suite Code Community at http://code.thinkgeo.com
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-06-2012 09:42 AM
David,

Thanks for your help in clearing up this issue. I decided I wasn't getting anywhere with it so I just didn't look at the forum for about a week. I think everyone here agrees we would like more performance out of SQL Server (yes, it's a never-ending quest) but not with the restrictions of how many layers we can open or to have to go back and track down every SQL layer to be sure we close it or to have to extend the SQL layer code just to get back the functionality we've had for the last two years. Your last response was almost a week ago, so I'm going to guess this would now be in the daily build. When I get a chance I'll download the latest and give it a try.

Thanks,
Allen
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-06-2012 09:45 AM
So when I create a SQL layer, I'd add SqlConnectionMode.Default to duplicate what we had in 4.5, right?
EdgarUser is Offline
MVP
MVP
Posts:715
Avatar

--
08-06-2012 07:58 PM
Allen,

No, you don't need to change anything if you want the connection AutoClose, we made it AutoClose in our code by default.

Regards,

Edgar

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

DavidUser is Offline
MVP
MVP
Posts:1534
Avatar

--
08-07-2012 12:22 AM
Allen,

I want to clear up any confusion here. The enumeration for the mode is Default, AutoClose and KeepOpen. The property on the layer defaults to Default. The functionality of the enumeration of Default is AutoClose. I hope that is clear, I think that is what you wanted to know right?

Also it is out in the daily builds as of the date of my previous post.

David
- Need sample code? Check out the Map Suite Code Community at http://code.thinkgeo.com
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-07-2012 06:24 AM
David and Edgar,

My apologies...I missed where David wrote "we have added an additional set of constructors". At first glance I thought the existing constructors had been modified to add a new argument, but after I left the office I realized that would have broken a lot of code. I am going to download the daily build now and give this a try.

Thanks,
Allen
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-07-2012 08:22 AM
I just came to the conclusion that either I have never done this before or it's been so long since I did it I don't remember.

I downloaded 6.0.85.0 to get these new SQL layer changes. In Visual Studio I have a toolbox tab called "Map Suite" which I do not want to disturb, at least until I know that I want to use 6.0.85.0 for production, so I created a new tab, "Map Suite Daily Build". To add MapSuite to it, I do "Choose Item". The daily build, since it was not "installed", does not appear in the .NET tab, so I click on "Browse". I find the folder where I stored the daily build DLLs, and pick "Desktop Edition". I am prompted with a security warning that the file was downloaded, etc, and might potentially harm my computer and I should only load assemblies from a publisher I trust. If I say "Yes" to do it anyway, the new DLL is not loaded into the .NET list. One time I tried to use the "Strongly Named" DLLs, which worked, but then started throwing a lot of errors when I tried to use the component inside Visual Studio.

Any idea what I'm doing wrong? This is the first time doing something like this under Windows 7 and Visual Studio 2010. If I did this in the past it was under XP and VS 2008, which was probably more forgiving.

Allen
RyanUser is Offline
ThinkGeo Support
MVP
MVP
Posts:837
Avatar

--
08-07-2012 03:05 PM
Hi Allen,

The name of the item in the ToolBox should be 'WinformsMap' and I believe by default is added to the 'General' section of the Toolbox. Let me know if you find it.

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-08-2012 10:23 AM
Hi Ryan,

I have WinformsMap under "MapSuite", which might have been a tab I created right after installing the 6.0 release and has always been in the toolbox. (This is a new PC that didn't have MapSuite on before.) The General section is empty. I am trying to add a SECOND WinformsMap under a different tab (I called it MapSuite Daily Build) so I can load the daily build but Visual Studio is fighting me and refusing to add it to the toolbox. Otherwise I can't drop a 6.0.85.0 version WinformsMap into my project to test these changes. (I tried creating a WinformsMap dynamically and loading it to the form, but it doesn't work right: when I debug and get to the map Refresh call it just hangs and never finishes. I was hoping that would work because then I couldget around this problem adding the daily buld to the toolbox.) If what I'm doing isn't clear, I can take some screen shots to show what's going on.

Allen
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-08-2012 10:35 AM
Ryan,

I have figured out one item...when I looked at the DLL properties there is a "block file from other computer" checkbox that was set. When I unchecked it, the error message goes away. But when I browse to the DLL in the "Choose Toolbox Items" and select the 6.0.85.0 DLL, it does not appear there, just the 6.0.0.0 version. Could it be thinking these two are the same and not adding it to the list of DLLs?

Allen
AllenUser is Offline
Level 4
Level 4
Posts:285
Avatar

--
08-08-2012 10:36 AM
Ryan,

I have figured out one item...when I looked at the DLL properties there is a "block file from other computer" checkbox that was set. When I unchecked it, the error message goes away. But when I browse to the DLL in the "Choose Toolbox Items" and select the 6.0.85.0 DLL, it does not appear there, just the 6.0.0.0 version. Could it be thinking these two are the same and not adding it to the list of DLLs?

Allen
You are not authorized to post a reply.
Page 2 of 3 << < 123 > >>


Active Forums 4.2