# Error while calling cdb\_set\_namespace , how to handle?

**URL:** https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480
**Category:** CDB and CDB API
**Created:** [August 22, 2017, 2:39pm UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480 "2017-08-22T14:39:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bkannadassan](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bkannadassan](https://dmap-community.ductus.global/u/bkannadassan)
#### Post date: [August 22, 2017, 2:39pm UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480/1 "2017-08-22T14:39:17Z")

</div>

Hi All!

I see that in the confd user guide example we are performing…

cdb\_start\_session

cdb\_set\_namespace ==\> if error return

shouldn’t we be closing the cdb\_session before return ?. Now what happens if their is a failure and we again start session, do we get error like below ?.. We see this issue want to know why its happening

**CDB\_NEW\_SESSION DEBUG Bad protocol usage or unexpected retval - must call END\_SESSION before NEW\_SESSION**

rgds  
Balaji

---

<div class="post-metadata">

### Author: ![jjohansson](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jjohansson](https://dmap-community.ductus.global/u/jjohansson)
#### Post date: [August 23, 2017, 12:44pm UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480/2 "2017-08-23T12:44:38Z")

</div>

You should call cdb\_close() or cdb\_end\_session() before calling cdb\_start\_session() again. For more information, see confd\_lib\_lib man-page.

---

<div class="post-metadata">

### Author: ![bkannadassan](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bkannadassan](https://dmap-community.ductus.global/u/bkannadassan)
#### Post date: [August 28, 2017, 5:48am UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480/3 "2017-08-28T05:48:29Z")

</div>

Thanks for the reply. I see the lock is removed if we do a cdb\_end\_session, but is it mandatory to call cdb\_close ?. I see from user guide that it releases the lock if we call cdb\_end\_session.

---

<div class="post-metadata">

### Author: ![jjohansson](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jjohansson](https://dmap-community.ductus.global/u/jjohansson)
#### Post date: [August 28, 2017, 5:10pm UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480/4 "2017-08-28T17:10:12Z")

</div>

cdb\_close() _or_ cdb\_end\_session(), no need to call both.

---

<div class="post-metadata">

### Author: ![bkannadassan](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bkannadassan](https://dmap-community.ductus.global/u/bkannadassan)
#### Post date: [August 29, 2017, 2:00am UTC](https://dmap-community.ductus.global/t/error-while-calling-cdb-set-namespace-how-to-handle/1480/5 "2017-08-29T02:00:24Z")

</div>

Thanks for the prompt response…
