planetfederal / qgis-suite-plugin

GNU General Public License v2.0
25 stars 17 forks source link

Error when trying to add a layer from GeoServer #85

Open vdeparday opened 10 years ago

vdeparday commented 10 years ago

I am using the master on Mac with QGIS 2.0.1 with the GeoNode demo server: http://beta.dev.geonode.org

I tried to drag a layer from GeoServer to the workspace and I got the following error with the boxes_with_date layer The layer http://beta.dev.geonode.org:8080/geoserver/wfs?srsname=EPSG:4326&typename=geonode:boxes_with_date&version=1.0.0&request=GetFeature&service=WFS is not a valid layer and can not be added to the map

Then I tried San Andres layer relief and it worked Somehow then the boxes with dates layer worked

but then none of the layers can be added (although they worked in the same session) for instance: The layer http://beta.dev.geonode.org:8080/geoserver/wfs?srsname=EPSG:4326&typename=geonode:san_andres_y_providencia_coastline&version=1.0.0&request=GetFeature&service=WFS is not a valid layer and can not be added to the map

volaya commented 10 years ago

It seems that the problem is a QGIS problem. If you go to the QGIS Python console and try this:

uri = "http://beta.dev.geonode.org:8080/geoserver/wfs?srsname=EPSG:4326&typename=geonode:boxes_with_date&version=1.0.0&request=GetFeature&service=WFS" layer = QgsVectorLayer(uri, "layername", "WFS") print layer.isValid()

sometimes it prints True, sometimes False. It seems that it depends on how it can connect to the server. If there is some issue, I think it doesn't retry or do anything else, so the layer is invalid (just like if you had entered a wrong URL), and when then it tries to add it to the canvas, it fails.

vdeparday commented 10 years ago

Thank you for the quick answer and for looking into it. I think we will need a solution (maybe a fix in QGIS) as it is happening for me 95% of the time on the connection that I am using which makes the plugin unusable. On the other hand, the upload worked fine.

ischneider commented 10 years ago

One thing that comes to mind is that httplib2 is not thread safe and responses can be garbled if a single instance is used by 2 threads.

volaya commented 10 years ago

In this case, it is QGIS, not the plugin, who connects to the server to get the layer. The plugin just prepares the URL and passes it to QGIS on the drop event, and QGIS connects, but not using httplib2. Basically, there is no httplib2 involved in dragging & dropping a layer onto the QGIS canvas.

A quick solution would be to disable the drag operation and leave only the "add to project" command in the context menu, and there add some mechanism for checking that the layer can be accessed, or at least implement soe kind of retry.

vdeparday commented 10 years ago

This issue is really critical as it prevents from using the plugin entirely to pull and display layers (although the publishing worked well in most cases, will report some bugs soon) I tried one night to pull layer and it was working fine and then during the workshop the day after, I kept getting the error and couldn't add a layer although the GeoServer is on my local machine. At the exact same time, adding the same layer with the 'Add WFS' dialog in QGIS worked totally fine there was no issue even with 30 users at the same time on the same GeoServer so there must be some code in the 'Add WFS' that takes care of that and that is different from just: layer = QgsVectorLayer(uri, "layername", "WFS")

ScottEvil commented 10 years ago

Anyone find a workaround for this issue? I'm having the same issue @vdeparday was having. I'm using QGIS 2.2.0 on Mac OSX 1.7 and the latest update from the Boundless plugin. Target is GeoServer 2.4.

ScottEvil commented 10 years ago

I've been working with this for a while today. It appears to be much harder to reproduce this when I drag the layer from the QGIS browser window. It's happening much more often when I add from the OpenGeo Explorer.

vdeparday commented 10 years ago

After a long time, I actually re-did some testing yesterday and I had the same issue with demo.geonode.org and I think even more issues with servers hosted further and with lower bandwidth. And you can confirm that it is working all the time with the simple Add WFS or Add WMS tools? Maybe we should like at how they are implemented. I think one different between the two manipulations that you are describing is that one is pulling the style and the other one isn't (see issue #73) other than than I will let @volaya chime in

ScottEvil commented 10 years ago

@vdeparday The simple Add WFS and Add WMS tools haven't given me any problems.

volaya commented 10 years ago

Should be fixed now. I am able to add all the layers in the demo geonode server without problems. the problem was in the Uri being used.

there is however, one issue. Some layers (in particular, now it happens with the "localidades" layer) are in the server but not exposed and available through WFS, so they will fail. There should be two parameters: "advertised" and "enabled" for each layer, so we could filter based on that, but they do not seem to be used.

See, for instance, here: http://beta.dev.geonode.org:8080/geoserver/rest/layers/localidades.xml

So, in short, all layers that work fine using the "add WFS layer..." menu item, should work fine now when dragging from the Suite plugin, but some layers which are nor enabled (if they exist) will cause the same exception. These are the layers that will not show up in the "add WFS layer" dialog, and only appear in the catalog listing in the Suite plugin.

Please, test and confirm that is working properly now

ScottEvil commented 10 years ago

Will the version with the fix be available soon as an update through the plugin manager or do I need to get a different build through another means?

volaya commented 10 years ago

There are no plans to release a new version soon, so you should install from the github repo

ScottEvil commented 10 years ago

@volaya helped me troubleshoot with the updated code and the behavior I'm seeing seems to stem from QGIS not properly using the authentication for a WFS. The Boundless plugin is getting the full list of layers but the Add WFS in QGIS only sees the public layers. That's the only reason the QGIS portion was working for me. I updated an existing QGIS bug here: http://hub.qgis.org/issues/9234

vdeparday commented 10 years ago

I just tried the master and QGIS 2.2 and it is now working for me for all layers except as Scott mentioned for layers that requires authentication with 2.2. Thanks a lot for the fix.

I had a look at http://hub.qgis.org/issues/9234 and apparently it is fixed but when I tried to add the catalog demo.geonode.org user: admin pwd: admin , it freezes with QGIS 2.4 RC when it works at the same moment with QGIS 2.2 so it looks like something got broken with the QGIS 2.4.

vdeparday commented 10 years ago

Once this bug is fixed with 2.4, it would be great to a do a new release to the plugin repo as I would like to use the plugin at some training workshops and this one was the main bug that was preventing me from it.