Search This Blog

Saturday, November 30, 2019

free for developers

Developers and Open Source authors now have a massive amount of services offering free tiers, but it can be hard to find them all in order to make informed decisions.


https://free-for.dev/#/?id=stun-webrtc-web-socket-servers-and-other-routers

Tuesday, October 22, 2019

C# Controller - accept any json in POST (not typed)

in case you want to get any json string (not typed) , you can try the next code snippets

             [HttpPost]
        public ActionResult Bot(string request)
        {
            Request.InputStream.Position = 0;
            var input = new StreamReader(Request.InputStream).ReadToEnd();

            JObject json = JObject.Parse(input);
           ...........
       }

Tuesday, October 15, 2019

Gor - GoReplay - capturing and replaying live HTTP traffic

Gor is an open-source tool for capturing and replaying live HTTP traffic into a test environment in order to continuously test your system with real data. It can be used to increase confidence in code deployments, configuration changes and infrastructure changes.

usefull links 
https://github.com/buger/goreplay/wiki/Running-on-Windows



be aware if you listen to port 8000 you must have a live server on this port up and running.

on windows i get failed to listen on the localhost ( some loopback issue on the netwrok) , there are some post/articles about this issue  e.g. https://github.com/buger/goreplay/issues/440

but non- of them help me to capture from local host.
so i access my web server from remote and its work perfectly .
mean:
gor is running from the webserver machine e.g MyServer , and connect to port e.g 7001.
i access to this webserver from remote machine via url , e.g. http://MyServer :7001

starter command
-- will replay only POST method from the file requests.gor
goreplay.exe --input-file requests.gor --output-http="http://localhost:7001"  --http-allow-method POST

-- replay all request
goreplay.exe --input-file new_contact_0.gor --output-http="http://hlvm-yanivt:7001" 

--replay all request and log response 
goreplay.exe --input-file new_contact_0.gor --output-http="http://hlvm-yanivt:7001" --output-http-track-response --input-raw-track-response --output-file=new_contact_play.gor

--start record and log response
goreplay.exe --input-raw :7001 --output-stdout  --output-http-track-response --input-raw-track-response --output-file=requests.gor 


enjoy
Yaniv Tzanany

Thursday, September 19, 2019

CreateProcess failed from Windows service - windows child process limits

I  built a windows service that spawn child process , i  noticed that after 100 childs process creation , i get failed to create new process, no error , just return immediately right after creation.
i am waiting on each process handle.

when i run the service from console , all work fine.
when i set my service to interact with  desktop , seems to be fine.

from google search i found those article who helps me at least to increase the number of processes .

child process limits in service context and conhost.exe

How to increase the maximum number of child processes that can be spawned by a windows service — desktop heap limits


i used in my case DETACHED_PROCESS as a parameter to CreateProcess api , and i managed to increase from 100 to about 300 childs.

   bSuccess = CreateProcess(NULL,
(LPSTR)(LPCTSTR)commandLine ,    // command line
  NULL,          // process security attributes
  NULL,          // primary thread security attributes
  TRUE,          // handles are inherited
  DETACHED_PROCESS,  // creation flags
  NULL,          // use parent's environment
  NULL,          // use parent's current directory
  &siStartInfo,  // STARTUPINFO pointer
  &piProcInfo);  // receives PROCESS_INFORMATION

still need to check how to increase the desktop heap ...

i found this solution at How to increase the maximum number of child processes that can be spawned by a windows service — desktop heap limits

WARNING: this affects the desktop heap of all services! Do not make it larger than necessary or you will push the system to consume more resource and you may bump up against problems in the total available desktop heap size.
If you find that you cannot open more than about 100 total projects, even on a very large RAM server, you may have run into a limit of the Windows "desktop heap size".
The problem is that service sessions under windows (where the services run) have less of this "desktop heap" space available for creating windows.
The short version is:
  • Services get smaller desktop heaps than interactive sessions.
  • Desktop heap size limits the number of windows
  • Each sub-server creates one or more “windows” even if we can’t see them.
Solution:
  1. Backup your registry before making any changes!
  2. Run regedit.exe as administrator
  3. Edit the registry value:
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
    
  4. You will see a string like:
    %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16
    
The critical bit is:
SharedSection=1024,20480,768
The second number (20480) is the size for interactive sessions. The third number (768) is the size of non-interactive (services) sessions. Note how the third number is 26x smaller than the second. Experimentally, we found that changing this to:
SharedSection=1024,20480,2048
Increased the project limit from 106 to 270, almost perfectly scaling with the heap size. Pick a value that reflects the maximum number of projects that you expect to be opened simultaneously by all users on the system. Do not make this value larger than necessary, and no larger than 8192, as each service in your system will consume more of a precious resource.

good luck
yaniv tzanany

Monday, September 16, 2019

Android Emulator: Process finished with exit code -1073741819

the solution that works for me was

  1. find your avd folder.(If your using Windows OS, the default path is C:\Users\USER_NAME\ .android\avd\YOUR_VIRTUAL_DEVICE_NAME.avd)
  2. open the file config.ini
  3. find hw.gpu.mode and set it to off (hw.gpu.mode=off)
  4. launch the AVD manager
  5. launch your virtual device.


reinstall emulator + haxm didnt worked for me only the above.

enjoy 
Yaniv Tzanany

Monday, August 12, 2019

Dialog flow advanced samples

very good video how to use context and values between intents.





Great video how to connect dialog flow with firebase DB - write and read from/to DB



Integrate dialog with external api



Wednesday, July 17, 2019

JNI calls in Multi-thread application (or call back from java to C++ )

When you try to accee
Recently i noticed when i tried to access my global JNIEnv  from other thread ( not the one who initialize it) , i get failed to call to FindClass.

from the document :
"The JNI interface pointer (JNIEnv) is valid only in the current thread"

so you must call to AttachCurrentThread() method first on the new thread, and detach it via DetachCurrentThread()

you can read more about it at 
The Invocation API



enjoy
Yaniv Tzanany

Sunday, June 23, 2019

gcloud deploy to appengine

very easy way to deploy nodejs app on google engine.

create your index.js file
create your app.yaml file
app.yaml should contains only one line , in my easy test.
runtime: nodejs10


on the same folder i run the next command

gcloud init
 gcloud projects create yaniv2cappengine
gcloud app create --project=yaniv2cappengine
gcloud config set project yaniv2cappengine
 gcloud app deploy

that all - enjoy
Yaniv Tzanany

Thursday, May 16, 2019

Azure for developer az-203 - session


https://docs.microsoft.com/en-us/azure/

for power shell use AZ package.

Azure Rest Api Browser - to test all Azure rest API

Azure quick start templates  - list of predefined template to use .

Azure Storage Explorer - a tool to manage storage on AZURE from your desktop, you might need to install newer emulator (msi installer)

File sharing storage type - its like a network drive.

SQL server - there is two mode of price vCpu && DTU - dtu is chipper but you need to be aware.

SQL Azure Tutorial
https://docs.microsoft.com/bs-latn-ba/azure/sql-database/sql-database-single-database-get-started


DDD Domain-driven design   - new design pattern. 


App Service Plan - its multi-tenant .
App Service Environment  - your private VNet , single tenant

in  Service plan we create web app , or Api app.

the way to host web app in azure is to:
create app service plan , under resource group.

in the web-app under azure  - there is log stream that you can see all the trace command from c#.
system.dagnostic.trace.writeln

Use Swagger to expose your API in a friendly name.

Security:
Azure AD (AAD)
ADB2C

Authentication method :
Windows Auth (NTLM/kerberos)
Form Auth     (user)
Basic Auth    (user or api)
Digest
SAML            (ws-*)
Bereer(JWT) -- jwt.io   (rest  json)   ---  use Open ID Connect , OAuth 2.0 - we get token with claims


Monitor
create application insights resource
there is ability to report from any agents such as windows console application to report to Azure monitors tools (insights) you can add simple traces and event that contains more details .

handling transient errors - (temporary error , such as no network, locks on db , busy i/o)
in transient error - we will do retry first , in case its failed we will wait X units of time , till cancel.
X will be exponential time ( 2,4,8..... CANCEL)

Enterprizelibrary.transientlibarry

Dockers:
install docker for windows desktop
tutorial could be found at https://docs.docker.com/docker-for-windows/

Azure ACI - Azure containers instances
Azure ACR - Azure container registry
Azure AKS  - Azure Kubernetis Service 

Thursday, April 25, 2019

Background task with asp.net - like service - job

great way to use cache mechanize
https://stackoverflow.blog/2008/07/18/easy-background-tasks-in-aspnet/

also quartz.net is a great way , make sure to use the right version - that will fit to your .net runtime
 https://www.quartz-scheduler.net/

https://www.mikesdotnetting.com/article/254/scheduled-tasks-in-asp-net-with-quartz-net
i used 2.6.2 for .net 4.5.1
https://www.nuget.org/packages/Quartz/2.6.2
via nuget
nuget PM Install-Package Quartz -Version 2.6.2

enjoy
Yaniv Tzanany

Thursday, April 18, 2019

Thursday, February 28, 2019

webrtc - samples and hacks

https://webrtchacks.com/own-phoneco-with-webrtc/


https://webrtchacks.com/baby-motion-detector/

Thursday, February 21, 2019

FCM push via ARC chrome extension

you can send push via ARC  this chrome extension 
you can do it via postman as well (https://medium.com/android-school/test-fcm-notification-with-postman-f91ba08aacc3)


POST to https://fcm.googleapis.com/fcm/send
headers:
content-type  application/json
Authorization   key=[get the key from firbase messageing)

in the body write your json  
e.g. sample 
{
                ""priority"": ""high"",
                ""time_to_live"": 86400,
                ""to"": ""{0}"",
                ""notification"": {
                                                              
                        },
                ""data"": {
                            ""title"": ""{1}"",
                            ""body"": ""{2}""  
                        ""basic"":""{3}"",
                        ""firstname"":""{4}"",
                        ""lastname"":""{5}""
                        }
            }"