diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index 7ab096cfa901074aee77f59791ecd51e31d671b3..156efc3f408fce0b67e3ee07d8bd51f13238b7c4 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -811,7 +811,7 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname)
     }
     GmshNetworkClient *c = OnelabDatabase::instance()->useAsNetworkClient(address, port, name);
     if(c == NULL) {
-      Error("Unable to connect ONELAB server");
+      Error("Unable to connect ONELAB server (%s)", sockname.c_str());
       Exit(1);
     }
     _onelabClient = c;
@@ -821,7 +821,7 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname)
     SetOnelabString(name + "/9CheckCommand", "-", false);
     SetOnelabString(name + "/9ComputeCommand", "-3", false);
     std::vector<onelab::string> ps;
-    _onelabClient->get(ps, name + "/Action", true); // FIXME good idea ?
+    _onelabClient->get(ps, name + "/Action");
     if(ps.size()){
       Info("Performing ONELAB '%s'", ps[0].getValue().c_str());
       if(ps[0].getValue() == "initialize") Exit(0);
diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp
index 85288c7143a68330156afa7a8c690419ae459a50..780fcd6645ef8266a0bca3e2583f6f1f84796175 100644
--- a/Common/onelabUtils.cpp
+++ b/Common/onelabUtils.cpp
@@ -87,7 +87,10 @@ namespace onelabUtils {
       std::vector<onelab::string> ps;
       OnelabDatabase::instance()->get(ps, client + "/1ModelName");
       if(ps.empty()){
-        std::vector<std::string> split = SplitFileName(GModel::current()->getFileName());
+        OnelabDatabase::instance()->get(ps, "Gmsh/1ModelName");
+        std::vector<std::string> split;
+        if(!ps.empty()) split = SplitFileName(ps[0].getValue());
+        else split = SplitFileName(GModel::current()->getFileName());
         std::string ext = "";
         OnelabDatabase::instance()->get(ps, client + "/FileExtension");
         if(ps.size()) ext = ps[0].getValue();
diff --git a/Geo/GModel.h b/Geo/GModel.h
index dc4d26914e5af40e27c8c545259048143e832379..ebef3c99f45f757d3c7b6ca9ee60e14f2790192e 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -219,6 +219,9 @@ class GModel
   // get/set the model file name
   void setFileName(std::string fileName)
   {
+#ifdef HAVE_ONELAB2
+    Msg::SetOnelabString("Gmsh/1ModelName", fileName, false);
+#endif
     _fileName = fileName;
     _fileNames.insert(fileName);
   }
diff --git a/contrib/onelab2/OnelabDatabase.cpp b/contrib/onelab2/OnelabDatabase.cpp
index 5ff0521a513467f99cb30152ab5ae9ccde8662ad..34314b9bba0f3c6b648d51e8614a144a1fe50a4a 100644
--- a/contrib/onelab2/OnelabDatabase.cpp
+++ b/contrib/onelab2/OnelabDatabase.cpp
@@ -13,10 +13,9 @@ DWORD WINAPI OnelabDatabase_listen(LPVOID arg)
   UInt8 buff[1024];
   int recvlen = 0;
   while(1) {
-    recvlen = OnelabDatabase::instance()->listen(buff, 1024);
-    if(recvlen == 1 && buff[0] == 'S')
-      break;
-    msg.parseMsg(buff, recvlen);
+    recvlen = OnelabDatabase::instance()->listen(msg);
+    if(recvlen <= 0)
+      break; // invalid len
     switch(msg.msgType()) {
       case OnelabProtocol::OnelabStop:
         std::clog << "\033[0;35m" << "Client is going to stop" << "\033[0;0m" << std::endl;
diff --git a/contrib/onelab2/OnelabDatabase.h b/contrib/onelab2/OnelabDatabase.h
index 0bc64b96400dbc7b33da9ca689b9a966a6f65e50..f0c9af615b358ccba39057f21138a460ed410585 100644
--- a/contrib/onelab2/OnelabDatabase.h
+++ b/contrib/onelab2/OnelabDatabase.h
@@ -93,7 +93,6 @@ public:
         return _client;
       }
       else {
-        Msg::Error("Unable to connect to the server!");
         return NULL;
       }
     }
@@ -115,6 +114,10 @@ public:
     if(_client) return pthread_join(_listenThread, NULL);
     return pthread_join(_serverThread, NULL);
   }
+  int listen(OnelabProtocol &msg) {
+    if(_client) return _client->recvfrom(msg);
+    return 0;
+  }
   int listen(UInt8 *buff, unsigned int maxlen){
     if(_client) return _client->recvfrom(buff, maxlen);
     return 0;
diff --git a/contrib/onelab2/OnelabNetworkClient.h b/contrib/onelab2/OnelabNetworkClient.h
index 3e09c9fa72ffcafdc51ec38db49bf9d374024ed6..6a20005bf2d9f85c0996bd2bd08f33a22e92f93b 100644
--- a/contrib/onelab2/OnelabNetworkClient.h
+++ b/contrib/onelab2/OnelabNetworkClient.h
@@ -61,7 +61,7 @@ public:
 		}
 		return false;
 	}
-	template <class T> bool get(std::vector<T> &ps, const std::string &name, bool needed="false"){
+	template <class T> bool get(std::vector<T> &ps, const std::string &name, bool needed=false){
 		if(_parameterSpace->get(ps, name, this->_name) && ps.size() == 0) {
 			if(requestParameter(ps, name)) {
 		    if(needed) {// wait for the answer
diff --git a/contrib/onelab2/OnelabProtocol.cpp b/contrib/onelab2/OnelabProtocol.cpp
index 1fd11629423aee878b2017f56febea726ebfe298..962ec1578c60367f6cee652a4b14d379b3f4ec90 100644
--- a/contrib/onelab2/OnelabProtocol.cpp
+++ b/contrib/onelab2/OnelabProtocol.cpp
@@ -125,86 +125,6 @@ UInt32 OnelabProtocol::parseMessage(UInt8 *buff, UInt32 len)
  
   return len-parsed;
 }
-UInt32 OnelabProtocol::parseMsg(UInt8 *buff, UInt32 len)
-{
-	this->clearAttrs();
-	if(len < 4) throw ERROR_BUFFER_TOO_SMALL;
-	UInt8 *ptr = buff;
-	UInt8 version = 0;
-	ptr = parse(ptr, version);
-	if(version != ONELAB_VERSION) throw ERROR_ONELAB_VERSION;
-	ptr = parse(ptr, _type);
-	ptr = parse(ptr, _size);
-  //std::cout << "current version is " << (int)ONELAB_VERSION << ", message version is " << (int)version << "(length is " << len << ", size is "<< _size <<" )" << std::endl;
-
-	UInt8 *payload = ptr;
-  unsigned short parsed = 4;
-	unsigned short size = _size;
-
-	while(size >= 4) {
-		UInt16 attrType = 0;
-		UInt16 attrSize = 0;
-		ptr = parse(ptr, attrType);
-		ptr = parse(ptr, attrSize);
-		size -= 4;
-		std::cout << "Try to parse an attribute of type 0x" << std::hex << (UInt16)attrType << std::dec << " and size : " << attrSize << std::endl;
-		if(attrSize > size) throw ERROR_BUFFER_TOO_SMALL;
-		switch(attrType) {
-			case OnelabAttr::Message:
-				this->attrs.push_back(new OnelabAttrMessage());
-				((OnelabAttrMessage *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-			case OnelabAttr::Number:
-				this->attrs.push_back(new onelab::number());
-				((onelab::number *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-			case OnelabAttr::String:
-				this->attrs.push_back(new onelab::string());
-				((onelab::string *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-      case OnelabAttr::Region:
-        this->attrs.push_back(new onelab::region());
-        ((onelab::region *)this->attrs.back())->parseAttribute(ptr, attrSize);
-        break;
-      case OnelabAttr::Function:
-        this->attrs.push_back(new onelab::region());
-        ((onelab::function *)this->attrs.back())->parseAttribute(ptr, attrSize);
-        break;
-			case OnelabAttr::Start:
-				this->attrs.push_back(new OnelabAttrStart());
-				((onelab::string *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-			case OnelabAttr::Parameter:
-				this->attrs.push_back(new OnelabAttrParameterQuery());
-				((OnelabAttrParameterQuery *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-      case 0x10:
-        this->attrs.push_back(new OnelabAttrAction());
-				((OnelabAttrAction *)this->attrs.back())->parseAttribute(ptr, attrSize);
-				break;
-      case 0x0b:
-				this->attrs.push_back(new OnelabAttrFileQuery());
-				((OnelabAttrFileQuery *)this->attrs.back())->parseAttribute(ptr, attrSize);
-        break;
-      case 0x0c:
-				this->attrs.push_back(new OnelabAttrFile());
-				((OnelabAttrFile *)this->attrs.back())->parseAttribute(ptr, attrSize);
-        break;
-			default:
-        // FIXME unknown attribute
-				//if(attrSize != 0) throw "Size of attr must be 0!";
-				/*this->attrs.push_back(new OnelabAttr(attrType));
-				this->attrs.back()->parseAttribute(ptr, &attrSize);*/
-				break;
-		}
-		ptr += attrSize;
-		size -= attrSize;
-    parsed += attrSize+4;
-	}
-  // TODO the boundary of the packet is not correct, keep the last bytes in a buffer (the rest is comming)
-  if(parsed != len) {std::cout << "parse - size left:"  << len-parsed << '-' << size << "(len is "<< len <<" and parsed is "<< parsed <<" )" << std::endl;}
-  return len-parsed;
-}
 void OnelabProtocol::showMsg()
 {
 	std::cout << "\033[1m" << "\033[4m" << "Message type: 0x" << std::hex << (int)_type << "\033[0m" << std::endl