# TryConnectService() creating UNIX wakelock

**URL:** <https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015>\
**Category:** Legato Application Framework\
**Created:** [November 10, 2021, 5:55pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015 "2021-11-10T17:55:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 10, 2021, 5:55pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/1 "2021-11-10T17:55:51Z")

</div>

Hey,

when I use tryConnectService() to use my own api in other apps, the call to tryConnectService() is creating a UNIX wakelock that gets only remove if I use DisconnectService() for the corresponding api.

Can you give me some background information, for example about why connecting a service is setting a wakelock?

best regards,  
Nicolas Rausch

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 12:10am UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/2 "2021-11-11T00:10:26Z")

</div>

Do you mean it creates something here?

/sys/power/wake\_lock

---

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 11, 2021, 2:06am UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/3 "2021-11-11T02:06:31Z")

</div>

Yes under power/wake\_lock I get wakelocks called UNIX

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 2:12am UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/4 "2021-11-11T02:12:37Z")

</div>

what is the code doing inside TryConnectService()

---

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 11, 2021, 2:10pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/5 "2021-11-11T14:10:39Z")

</div>

that is what I want to know.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 2:29pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/6 "2021-11-11T14:29:44Z")

</div>

which component’s tryConnectService() are you calling?

---

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 11, 2021, 2:45pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/7 "2021-11-11T14:45:15Z")

</div>

a component I wrote by myself. Before you ask what that component is doing, can you tell me what it should not do, or rather which process would lead to a UNIX wakelock.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 2:46pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/8 "2021-11-11T14:46:30Z")

</div>

then what function is inside the tryConnectService() in your code?

You better attach your code here, very hard to understand what you are asking

---

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 11, 2021, 3:00pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/9 "2021-11-11T15:00:10Z")

</div>

this function is provided by the legato framework and is created automatically.  
See: [le\_mdmDefs\_interface.h - Legato Docs](https://docs.legato.io/17_07/le __mdm_defs__ interface_8h_source.html) (line47)

So basically the function provided by legato is trying to connect the current client thread to the service providing this API.  
So let´s say I wrote a component called printComp that only has a function called PrintHello() and all it does is calling LE\_INFO(“HELLO”).  
Now I am in another client thread and want to use the PrintHello() function api, to use that api I need to connect the client thread to the service(printComp in my case). To make this connection I use printComp\_tryConnectService(). When doing this i get a wakelock called UNIX. Only if I call printCompDIsonnectService() the UNIX wakelock is removed. I want to understand what using an api or rather to say what connecting client thread to a service has to do with wakelocks?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 3:09pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/10 "2021-11-11T15:09:40Z")

</div>

There is no need to call tryConnectService()

You can see this sample app

> **[legato-af/apps/sample/helloIpc at master · legatoproject/legato-af](https://github.com/legatoproject/legato-af/tree/master/apps/sample/helloIpc)**
>
> master/apps/sample/helloIpc

---

<div class="post-metadata">

**Author:** ![nicolas.rausch](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolas.rausch](https://forum.legato.io/u/nicolas.rausch)\
**Post date:** [November 11, 2021, 3:21pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/11 "2021-11-11T15:21:09Z")

</div>

when do I have to use tryConnectService then?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [November 11, 2021, 3:46pm UTC](https://forum.legato.io/t/tryconnectservice-creating-unix-wakelock/6015/12 "2021-11-11T15:46:22Z")

</div>

I don’t know, I never need to use this.
