<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chetan Pandey on Medium]]></title>
        <description><![CDATA[Stories by Chetan Pandey on Medium]]></description>
        <link>https://medium.com/@chetan177?source=rss-41a2ab1737f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tnqLLpxRpJ1oK98iak46oA.jpeg</url>
            <title>Stories by Chetan Pandey on Medium</title>
            <link>https://medium.com/@chetan177?source=rss-41a2ab1737f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 16:26:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chetan177/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enable SMTP in Grafana using Helm Charts in Kubernetes cluster(EKS)]]></title>
            <link>https://towardsdev.com/enable-smtp-in-grafana-using-helm-charts-in-kubernetes-cluster-eks-84e5849039cf?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/84e5849039cf</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 15:46:41 GMT</pubDate>
            <atom:updated>2022-08-09T06:56:00.473Z</atom:updated>
            <content:encoded><![CDATA[<p>Helm charts of most of the well-known opensource projects are kind of overwhelming at first glance. But they are made so that we can provide all the configuration while deploying, there is no need to edit docker or change anything just setup configuration. In this post, we will go through the setup of Gmail SMTP notification in grafana.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acleHZboN96GhPBnWTeMMA.jpeg" /><figcaption>Banner</figcaption></figure><p>We will deploy the helm chart from the official repo <a href="http://grafana.github.io/helm-chart">http://grafana.github.io/helm-chart</a></p><p>Before we start make sure you have the following dependencies things:</p><ul><li>helm</li><li>kubectl</li><li>Kubernetes cluster(minikube, kind, or any cloud provider) I am gonna use EKS.</li></ul><blockquote>Note: To setup minikube locally follow<a href="https://minikube.sigs.k8s.io/docs/start/"> Link</a></blockquote><p>Let&#39;s start first we need to import the helm chart using the following command</p><pre>helm repo add grafana https://grafana.github.io/helm-charts</pre><p>For setting up email notifications you need a Gmail account with 2FA enabled so that we can create an app password.</p><p>First let&#39;s enable IMAP in your Gmail account:</p><ul><li>Go to Gmail → See All Settings</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*ZV9NfvDIxAGxpoEizAm0RA.png" /><figcaption>See all settings</figcaption></figure><ul><li>Now enable IMAP → Hit save</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vr2a26drYCZB8f_Y-iZjfA.png" /></figure><ul><li>Now go to the Google Account Setting → Security [<a href="https://myaccount.google.com/security?hl=en">https://myaccount.google.com/security?hl=en</a>]</li><li>Click App Password (make sure you have 2fa on or you will not see this option)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeYChSzSL-D6KfU51uWXvw.png" /></figure><ul><li>Create an app password, Select App: Mail and Device: Others and click generate. It will give you a 16-letter password.</li></ul><blockquote>Lets deploy our grafana now</blockquote><p>Now let&#39;s create overider_values.yaml please fill update your password and user.</p><pre>env: <br>  GF_SMTP_ENABLED: &quot;true&quot;<br>  GF_SMTP_HOST: &quot;smtp.gmail.com:465&quot;<br>  GF_SMTP_PASSWORD: &quot;qqqquuuuiiiioooo&quot; #16 digit 2FA AppPassword<br>  GF_SMTP_USER: &quot;youremail<a href="/service/mailto:chetanpandey177.dev@gmail.com">@gmail.com</a>&quot;<br>  GF_SMTP_FROM_ADDRESS: &quot;youremail<a href="/service/mailto:chetanpandey177.dev@gmail.com">@gmail.com</a>&quot;<br>  GF_SMTP_FROM_NAME: &quot;Grafana&quot;</pre><ul><li>Create a namespace for your deployment</li></ul><pre>kubectl create namespace grafana</pre><ul><li>Now lets deploy the helm charts</li></ul><pre>helm install grafana grafana/grafana <br>--namespace grafana \<br>--set persistence.storageClassName=&quot;gp2&quot; \<br>--set persistence.enabled=true<br>--set adminPassword=admin \<br>--set service.type=LoadBalancer \<br>--values ./override_values.yaml</pre><p>This will deploy our grafana and create the following resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lm95Tgu8kXVv_AZVpsLfHA.png" /></figure><p>Now let&#39;s test it.</p><ul><li>Open grafana dashboard using the external IP (if not available expose your service)</li><li>Logging using user: adminand password: admin</li><li>Go to Alerting → Contact Point</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*z2idBcL5D3Kvbs2iJjWqnQ.png" /></figure><ul><li>Edit the default email contact point.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*5BS7JiN7vNZyQzxbZM25HA.png" /></figure><ul><li>Now enter your email and click <strong>Test</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*Z19oqG4s9UJr9XZYuKZMtQ.png" /></figure><ul><li>You should receive a test email like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*PT6RUyFUH06FseWmcngKhQ.png" /></figure><ul><li>Now setup your alters and notifications</li></ul><blockquote>Happy Helming !!!</blockquote><p><strong>References:</strong></p><ul><li><a href="https://artifacthub.io/packages/helm/grafana/grafana">grafana 8.5.2 · grafana/grafana</a></li><li><a href="https://github.com/grafana/helm-charts">GitHub - grafana/helm-charts</a></li><li><a href="https://kubernetes.io/">Production-Grade Container Orchestration</a></li><li><a href="https://minikube.sigs.k8s.io/docs/start/">minikube start</a></li><li><a href="https://helm.sh/">Helm</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84e5849039cf" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/enable-smtp-in-grafana-using-helm-charts-in-kubernetes-cluster-eks-84e5849039cf">Enable SMTP in Grafana using Helm Charts in Kubernetes cluster(EKS)</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed Timer using Golang And ActiveMQ]]></title>
            <link>https://towardsdev.com/distributed-timer-using-golang-and-activemq-3a2db46bfa68?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a2db46bfa68</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[timer]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 04:00:47 GMT</pubDate>
            <atom:updated>2022-08-05T10:56:47.663Z</atom:updated>
            <content:encoded><![CDATA[<p>In the times of microservices and distributed systems, we have a lot of complex architecture and robust solutions for most of the problems. But if we want to implement timers in a system we still tend to go for a sleep() in a thread, which is totally inefficient and resource-consuming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zsyeIsDyiXey_-IuAEX5g.jpeg" /><figcaption>Banner</figcaption></figure><p>Let&#39;s say I have a system that has a requirement of only 100 timers and the duration on the timer is always less than 5secs. I will probably go for the sleep solution. But If the requirement changes the duration can be between hours and the number of timers increases to 100K. Now how to solve the robustness and consistency of the timers?</p><blockquote>In this tutorial, we will go through how we can implement a simple distributed timer using a MessageQueue we will be using ActiveMQ, Same solution can be designed using RabbitMQ(with delay exchange plugin)</blockquote><h4>Our System will have 3 Components:</h4><p><strong>Producer: </strong>The producer will provide two components REST API to accept the timers and MessageQueue Producer which will write the message to the queue with the defined delay.</p><p><strong>Message Queue (ActiveMQ): </strong>We will be using ActiveMQ with stomp protocol. We will be using local docker installation, But if we want to use cloud managed service like AWS MQ we can use that as well.</p><p><strong>Consumer: </strong>Consumer will read the message when it is available in the queue and send an HTTP call to the endpoint which was provided earlier in the request we can send metadata and all other kinds of information if needed.</p><blockquote>The scheduling is handled by the MessageQueue</blockquote><p>Let&#39;s understand the functionality using an example of a 15sec timer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8np_Jzm04qav8E85EqkrWA.jpeg" /><figcaption>15-sec timer</figcaption></figure><ol><li>To initialize the timer we have to execute a <strong>StartTimer API</strong>(HTTP/ GRPC) with a parameter timer duration and a callback URL where we want to receive a notification that the timer is expired.</li></ol><pre>API: POST /v1/startTimer<br>Payload: <br>{<br>   &quot;duaration&quot;:15,<br>   &quot;callback_url&quot;:&quot;xyz.com&quot;,<br>   &quot;callback_method&quot;:&quot;POST&quot;<br>}<br>Response:<br>{<br>   &quot;message&quot;:&quot;success&quot;,<br>   &quot;timer_id&quot;:&quot;5af7f69b-2224-4c5f-8f2c-cf17804fdf65&quot;<br>}</pre><p>2. Producer will produce a message to the ActiveMQ queue with the header AMQ_SCHEDULED_DELAY=15000 the delay will be in milliseconds and request payload as the message body.</p><p>3. ActiveMQ will schedule the message after 15sec and it will be available to a consumer after time.Now()+15secs</p><p>4. Consumer will read the message and send a callback to the URL.</p><p>The Final HLD of the Distributed timer will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-DMDi7U6R8vwIE1hHUhRA.jpeg" /><figcaption>HLD</figcaption></figure><p>In the next Post, we will be building this distributed timer using Golang and Active MQ from scratch.</p><p><strong>References:</strong></p><ul><li><a href="https://pkg.go.dev/github.com/go-stomp/stomp">stomp</a></li><li><a href="https://go.dev/">The Go Programming Language</a></li><li><a href="https://activemq.apache.org/">ActiveMQ</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a2db46bfa68" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/distributed-timer-using-golang-and-activemq-3a2db46bfa68">Distributed Timer using Golang And ActiveMQ</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RabbitMQ Priority Queues with Golang Producer and Consumer.]]></title>
            <link>https://towardsdev.com/rabbitmq-priority-queues-with-golang-producer-and-consumer-92b10b5075d5?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/92b10b5075d5</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[priority-queue]]></category>
            <category><![CDATA[amqp]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Sun, 22 May 2022 10:19:17 GMT</pubDate>
            <atom:updated>2022-05-25T07:00:50.445Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will walk through implementing the RabbitMQ priority queue. We will be using Golang for building our consumers and producer. We will be using <a href="https://github.com/streadway">streadway</a>/<a href="https://github.com/streadway/amqp">amqp</a> library.</p><p>RabbitMQ is a lightweight and easy to deploy message queue. It supports multiple messaging protocols out of the box. We will be using AMQP (Advanced Message Queuing <strong>Protocol</strong>)</p><h3>Prerequisites:</h3><ul><li>Basic Golang</li><li>Basic Knowledge of RabbitMQ.</li></ul><h3>RabbitMQ:</h3><p>First, let&#39;s go through some of the basic terminologies of rabbitMQ.</p><ul><li><strong>Producer</strong>: An application that pushes messages to a rabbitMq exchange</li><li><strong>Consumer</strong>: An application that reads messages from the queue and processes them.</li><li><strong>Exchange: </strong>An exchange is responsible for routing the messages to different queues with the help of bindings and routing keys. There are multiple types of exchanges available in rabbitMQ.</li><li><strong>Binding: </strong>A binding is a link between a queue and an exchange.</li><li><strong>Routing key:</strong> A key that the exchange looks at to decide how to route the message to queues. Think of the routing key as an <em>address for the message</em></li><li><strong>Queue:</strong> Buffer that stores messages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xaeqGY9015h5izJg.png" /></figure><h4>Setup RabbitMQ:</h4><p>You can easily set up rabbitMq on your local machine or any cloud instance.</p><ul><li><strong>Run-on docker: </strong>You can easily run rabbitMq if you have docker setup on your local instance using this command.</li></ul><pre><em>run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management</em></pre><ul><li><strong>Install on Windows</strong>: Download the installer from the link: <a href="https://github.com/rabbitmq/rabbitmq-server/releases">https://github.com/rabbitmq/rabbitmq-server/releases</a></li><li><strong>Install on Ubuntu: </strong>Use the following commands to install rabbitMQ</li></ul><pre>apt-get update</pre><pre>echo &#39;deb http://www.rabbitmq.com/debian/ testing main&#39; | sudo tee /etc/apt/sources.list.d/rabbitmq.list</pre><pre>wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -</pre><pre>apt-get update</pre><pre>apt-get install rabbitmq-server</pre><pre>#start rabbitMq<br>systemctl start rabbitmq-server<br>systemctl enable rabbitmq-server</pre><p>Rabbit MQ management will start at the address <a href="http://localhost:15672/">http://localhost:15672/</a> and AMQP will start at localhost<em>:5672.</em></p><p><em>You can log in to the management console using the default password(guest: guest)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e1d4c9mpf-OoVg9PPRCOlw.png" /><figcaption>RabbitMq Management Console</figcaption></figure><p>Now let&#39;s create a producer and consumer with a priority queue. We will be using a topic exchange.</p><h4>Producer:</h4><p>The following code is for a simple producer written in go which will send messages with different priorities with a time gap of 1 sec.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9222dae46394f26a8c8a06ecdfaed5f0/href">https://medium.com/media/9222dae46394f26a8c8a06ecdfaed5f0/href</a></iframe><h4>Consumer:</h4><p>The following code is for a simple consumer written in go which reads a message and acknowledges it after 5 sec. The prefetch count is set to 1 for this consumer.<strong> Without QoS(Prefetch count) priority queue will not work</strong>. For more details check this: <a href="https://www.rabbitmq.com/consumer-prefetch.html">https://www.rabbitmq.com/consumer-prefetch.html</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1ab50309009859538dfbd73f68725a0/href">https://medium.com/media/f1ab50309009859538dfbd73f68725a0/href</a></iframe><p>Let&#39;s see it in action.</p><ul><li><strong>Start producer</strong>:</li></ul><pre>go run mqproducer/main.go</pre><ul><li><strong>Start Consumer</strong>:</li></ul><pre>go run mqconsumer/main.go</pre><ul><li><strong>Output:</strong> The output will look like this.</li></ul><p>With this configuration, the consumer reads messages with high priority first from the queue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B6PUYn7nnEv5BBEoWwqezQ.png" /></figure><blockquote>Note: If we didn&#39;t set up the prefect count to one the priority of the message will not work because the consumer will cache the messages as soon as they arrive in the queue (This is known as ahungry consumer).</blockquote><p><strong>Links for more information:</strong></p><ul><li><a href="https://www.rabbitmq.com/priority.html">Priority Queue Support</a></li><li><a href="https://www.rabbitmq.com/consumer-prefetch.html">Consumer Prefetch</a></li><li><a href="https://www.cloudamqp.com/blog/part1-rabbitmq-for-beginners-what-is-rabbitmq.html">Part 1: RabbitMQ for beginners - What is RabbitMQ? - CloudAMQP</a></li><li><a href="https://github.com/streadway/amqp">GitHub - streadway/amqp: Go client for AMQP 0.9.1</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92b10b5075d5" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/rabbitmq-priority-queues-with-golang-producer-and-consumer-92b10b5075d5">RabbitMQ Priority Queues with Golang Producer and Consumer.</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON Vs Protobuf — Which is the best way to store data in the cache (Redis).]]></title>
            <link>https://towardsdev.com/json-vs-protobuf-which-is-the-best-way-to-store-data-in-the-cache-redis-5e6b17d83ffa?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e6b17d83ffa</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[cache-memory]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[protobuf]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 08:45:15 GMT</pubDate>
            <atom:updated>2022-03-01T12:26:44.858Z</atom:updated>
            <content:encoded><![CDATA[<h3>JSON Vs Protobuf — Which is the best way to store data in the cache (Redis).</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AKdtgte6YzrxITDdqVTmEg.png" /></figure><p>In this article, we will be evaluating which is the better format for storing complex data in a cache(Redis).</p><p>As we know <strong>JavaScript Object Notation</strong> (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. JSON is a standard nowadays for designing API interfaces.</p><p>On the other side</p><p>Protocol Buffers (a.k.a., protobuf) are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. Data in a protobuf is not in a readable form.</p><h4>Prerequisites:</h4><ul><li>Basic Golang</li><li>Basic JSON and Protobuf Knowledge</li></ul><p>Let&#39;s dive into it. We will be using the Golang test bench for performing benchmarks between SET/GET operations with different formats JSON and Protobuf. We will be using Redis as a cache</p><blockquote>All the code is available here</blockquote><p><a href="https://github.com/Chetan177/go_json_vs_proto">GitHub - Chetan177/go_json_vs_proto</a></p><p>There are 4 methods in the main_test.go namely:</p><ul><li>BenchmarkSetJsonStruct<em> (bench set operation with JSON)</em></li><li>BenchmarkSetProto <em>(bench set operation with Proto)</em></li><li>BenchmarkGetJsonStruct<em> (bench get operation with JSON)</em></li><li>BenchmarkGetProto<em> (bench get operation with Proto)</em></li></ul><p>Let&#39;s take a look at BenchmarkSetJsonStruct and see what is it doing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a877c645a362bccf464a1cb173f0b411/href">https://medium.com/media/a877c645a362bccf464a1cb173f0b411/href</a></iframe><p>In this method, we are creating a connection with Redis using redigo the library and then creating a JSON string using a struct and saving that using in the Redis using SET operation.</p><p>The same is happening in the other method BenchmarkSetProtowhich is using protobuf</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b223ae98d471024e04ce2c5f272e4f39/href">https://medium.com/media/b223ae98d471024e04ce2c5f272e4f39/href</a></iframe><p>Let&#39;s run the benchmark and check the results.</p><pre>go test -bench=. -benchtime=10s -benchmem=true</pre><p>The results are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*RqSTR03Kt0giDbeMywkP4A.png" /></figure><blockquote>As we can clearly see JSON operations are consuming more memory as compared to the protobuf.</blockquote><p>JSON is using 416 B/op per Set and 536 B/op per Get, On the other hand, Protobuf is using 288 B/op per Set and 260 B/op per Get.</p><p>As the processing didn’t get that much better with protobuf but memory optimization is substantial.</p><p>Let&#39;s go ahead and check in the Redis as well using MEMORY USAGE the command which returns how many bytes a key is consuming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*NEfqA7X5epe9_ips82ZZnw.png" /></figure><p>Here we can see that Protobuf is a clear winner. If we talk about numbers protobuf is consuming<strong> 44.8% less space</strong> in Redis as compared to JSON.</p><blockquote>ProtoBuf is the winner here, so from next time if we get a use case like that we can choose protobuf blindly.</blockquote><p>Here are some references,</p><ul><li><a href="https://redis.io/commands/memory-usage">MEMORY USAGE - Redis</a></li><li><a href="https://www.sohamkamani.com/golang/json/">A Complete Guide to JSON in Golang (With Examples)</a></li><li><a href="https://developers.google.com/protocol-buffers/docs/gotutorial">Protocol Buffer Basics: Go | Protocol Buffers | Google Developers</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e6b17d83ffa" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/json-vs-protobuf-which-is-the-best-way-to-store-data-in-the-cache-redis-5e6b17d83ffa">JSON Vs Protobuf — Which is the best way to store data in the cache (Redis).</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC Request Routing (Header Based) AWS ALB]]></title>
            <link>https://towardsdev.com/grpc-request-routing-header-based-aws-alb-9934c1b4c67e?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9934c1b4c67e</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[client-server]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-alb]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Wed, 09 Feb 2022 09:18:47 GMT</pubDate>
            <atom:updated>2022-02-11T07:38:21.723Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we will walk through how to set up HeaderBased request routing in AWS Application load balancer for gRPC based services. This can be used for blue-green deployment, stick load balancing based on headers, and any other use case you want to solve regarding routing gRPC requests to a specific server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*TegUkh-gMH1LK2RY6KbSYQ.jpeg" /></figure><h3>Prerequisites:</h3><ul><li>Basic understanding of gRPC using GoLang(but you can use this with any language)</li><li>AWS account and Understanding of EC2</li></ul><blockquote>Let&#39;s create a simple HelloWorld app in go(I am using grpc-go example here).</blockquote><p>helloworld.proto is as follows you can create client-server using this if you wish not to use Golang</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6230cec8562452a90dad9e710ab01481/href">https://medium.com/media/6230cec8562452a90dad9e710ab01481/href</a></iframe><blockquote>The Code we will be using is available in the following repo <br>https://github.com/Chetan177/grpc-aws-alb-routing.git</blockquote><p>and structured as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*vfSkxmynsHoP_vQ4dtlm6w.png" /><figcaption>code structure</figcaption></figure><p>Here we have one client and two servers.</p><p>Make sure to edit client/client.go and update your domain and certificate for TLS connection.</p><pre>line 30: caFile:= &quot;/test/mykey.pem&quot;</pre><pre>line 31: creds, err := credentials.NewClientTLSFromFile(caFile, &quot;test.example.com&quot;)</pre><p>Let&#39;s create our deploy our application.</p><h3>Steps:</h3><ul><li>Create an EC2 instance of your choice if you are on free-tier use (t2.micro)</li><li>SSH to that machine and let&#39;s launch our gRPC servers</li><li>Make sure Go is set up properly, execute the following command to do it</li></ul><pre>rm -rf /usr/local/go &amp;&amp; tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz</pre><pre>export PATH=$PATH:/usr/local/go/bin</pre><pre>#verify<br>go version</pre><ul><li>Now let&#39;s clone the code from the repo</li></ul><pre>git clone <a href="https://github.com/Chetan177/grpc-aws-alb-routing.git">https://github.com/Chetan177/grpc-aws-alb-routing.git</a></pre><ul><li>And run both the servers</li></ul><pre>cd <a href="https://github.com/Chetan177/grpc-aws-alb-routing.git">grpc-aws-alb-routing</a><br>go run cmd/server-1/server.go &amp;<br>go run cmd/server-2/server.go &amp;</pre><p>Now server-1 will listen to port 50051 and server 2 will listen to port 50052</p><ul><li>Let&#39;s set up our ALB.</li><li>Go to Dashboard Ec2-&gt; Load balancer-&gt; Click on Create LoadBalancer and choose Application load balancer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*ueg1YtTERDYF7Y9-VhA45w.png" /></figure><ul><li>Create an internet-facing alb</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*ffr8_U7jv6D_1sW5GITpYw.png" /></figure><ul><li>Select the same VPC in which your ec2 is running and then select two subnets for the same</li><li>Create an HTTPS listener and select your domain certificate (the same we are using on the client)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLoij99FfqazFpx8DJiMFA.png" /></figure><ul><li>Now create a target group for the same</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*Jsh_gUnHDE72Sa2NYvVYQg.png" /></figure><ul><li>Add this target group and Create ALB</li><li>Now Repeat the same process and create target group grpc-dev-2 and port to 50052</li><li>Now go to your ALB and edit routing rules</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v0iWIQfhsJKt-zy_N7D3Ow.png" /></figure><ul><li>Create routes like this</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4bE0YDGBKQnlLbE_GJZJQ.png" /></figure><ul><li>Now copy the ALB public URL and run client/client.go from the local machine using the following command.(Make sure you have updated the certificate and domain)</li></ul><pre>go run cmd/client/client.go -addr=GRPC-TEST-....amazonaws.com:443</pre><p>You will get output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*djr4IUzeEooUufKgOsEgLA.png" /><figcaption>output</figcaption></figure><p>In this case our request with <em>x-route-id=blue </em>is routed to Server-1 and the request with x-route-id=green is routed to Server-2.</p><p>Some useful links and references are as follows:</p><ul><li><a href="https://aws.amazon.com/blogs/aws/new-application-load-balancer-support-for-end-to-end-http-2-and-grpc/">New - Application Load Balancer Support for End-to-End HTTP/2 and gRPC | Amazon Web Services</a></li><li><a href="https://pkg.go.dev/google.golang.org/grpc">grpc</a></li><li><a href="https://github.com/Chetan177/grpc-aws-alb-routing">GitHub - Chetan177/grpc-aws-alb-routing</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9934c1b4c67e" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/grpc-request-routing-header-based-aws-alb-9934c1b4c67e">gRPC Request Routing (Header Based) AWS ALB</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka (AWS MSK) with Golang]]></title>
            <link>https://towardsdev.com/kafka-aws-msk-with-golang-b3824a613e40?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3824a613e40</guid>
            <category><![CDATA[kafka-go]]></category>
            <category><![CDATA[aws-msk]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[message-queue]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 14:20:08 GMT</pubDate>
            <atom:updated>2022-02-07T09:04:53.881Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we will take a dive into creating consumer and producer applications in <strong>Golang </strong>using kafka-go with <strong>AWS MSK </strong>cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*RN5agxW2jXp0sJH4P6VzAw.png" /><figcaption>AWS MSK producer and consumer using Golang</figcaption></figure><h4>Prerequisites</h4><ul><li>Basic understanding of Message queues and why they are used?</li><li>Golang</li><li>AWS Account</li><li>Basic understanding of kafka</li></ul><h3>Kafka Overview?</h3><blockquote>Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day.</blockquote><p>Confluent has published a great video explaining what is Kafka and how it works.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F06iRM1Ghr1k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D06iRM1Ghr1k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F06iRM1Ghr1k%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/48b4777c71e5b1442b1b09e1e5a3e85d/href">https://medium.com/media/48b4777c71e5b1442b1b09e1e5a3e85d/href</a></iframe><p>So now, Assuming we have a basic understanding of Kafka it is pretty clear that Kafka is developed to solve problems at scale. But managing clusters can be a pain in complex systems so we prefer to use self-managed cloud services.</p><p>For Kafka, AWS provides MSK (Managed Streaming for Apache Kafka). So let&#39;s go ahead and create our first cluster.</p><h3>Create MSK cluster</h3><p>I am using the following configuration for my cluster you can configure it based on your requirements.</p><p><strong>Cluster configuration:</strong></p><ul><li>Size: <strong>kafka.t3.small</strong></li><li>Kafka version: <strong>2.6.2</strong></li><li>No of zones: <strong>2</strong></li><li>Broker per zone: <strong>1</strong></li><li>EBS: <strong>40GB</strong></li><li>Cluster configuration: <strong><em>MSK default configuration</em></strong></li></ul><p><strong>Networking:</strong></p><ul><li>Make sure you are creating a cluster in the same VPC where your consumer and producer will be running (on an ec2 instance)</li><li>We will be using private-subnet access so there is no need to configure any security group</li></ul><p><strong>Security:</strong></p><ul><li>Enable only unauthenticated access.</li><li>Disable all TLS encryption, your configuration should look like this</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*gOyaTrSLoQ4LxjK15x0Mxw.png" /></figure><blockquote>Note: you can enable IAM role-based authentication, for simplicity I am disabling all these settings. Because we will be focusing more on Go side.</blockquote><blockquote>If you face any issue you can refer to this documentation: <a href="https://docs.aws.amazon.com/msk/latest/developerguide/msk-create-cluster.html">https://docs.aws.amazon.com/msk/latest/developerguide/msk-create-cluster.html</a></blockquote><p>You can fetch cluster information from the MSK console by clicking on this link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0GytZTpuajuCXV69pQfBw.png" /></figure><blockquote>Now lets write our Consumer and Producer in Go</blockquote><h3><strong>Producer:</strong></h3><p>We will use <em>segmentio/kafka-go </em>client library to connect with our kafka cluster there are other libraries available as well. Our producer is very simple it does the following task.</p><ul><li>Create a topic with 3 partitions and 2 replicas</li><li>Produce data packets with keys ( Key-1 …) to our topic. We will be using Hash-based producing</li></ul><blockquote>producer.go</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8656a89abe1c708f4a557274591ea35/href">https://medium.com/media/c8656a89abe1c708f4a557274591ea35/href</a></iframe><p>Let&#39;s understand it,</p><p>Here BrokerURLs contains all the endpoints of the brokers which are available in the cluster</p><p>createKafkaTopic This method dials up to any broker in the cluster (we are using the first one), fetches the controller broker URL, and makes a connection to create the topic (we can create multiple topics as well).</p><p>newKafkaWriter This method creates a new writer for our topic. Here we are using Hash-based logic to write into the topic but there are other available as well <em>(check kafka-go documentation)</em></p><p>The main method execute them and produce messages to the topic using the writer</p><blockquote>Consumer.go</blockquote><p>Now let&#39;s write the consumer it is very simple.</p><ul><li>It creates a connection to the brokers and starts reading messages from the topic</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ade50687d4ebcc1411cb4f83adc1a17/href">https://medium.com/media/6ade50687d4ebcc1411cb4f83adc1a17/href</a></iframe><p>Let&#39;s understand the consumer now,</p><p>getKafkaReader This method creates a reader connected to the brokers and starts listing to the messages</p><blockquote>Now Lets see it in action.</blockquote><p>Launch an EC2 instance in the same VPC as of the MSK cluster and setup go in it.</p><p>Now go to the client information for the MSK cluster, Find broker URLs and update them in both consumer and producer.</p><blockquote>Start producing some messages</blockquote><p>Use the following command to start the producer</p><pre>go run producer/producer.go</pre><p>The output will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*G5zVuCO0uKsFRdFowFgl4g.png" /><figcaption>producer</figcaption></figure><p>Now start two instances of consumers</p><pre>go run consumer/consumer.go</pre><p>The output will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*VoszN71tj8CA6eQbHenucA.png" /><figcaption>consumer 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*rohHTnLrHDB2yltIH0i6Tg.png" /><figcaption>consumer 2</figcaption></figure><p>We are producing messages based on hashing that&#39;s why messages with the same keys are ending up in the same partition. <em>(Partition guarantees the sequence of messages)</em></p><blockquote>Now you can explore and build to solve some real-life problems using AWS MSK and Go.</blockquote><blockquote>Links:</blockquote><ul><li><a href="https://github.com/segmentio/kafka-go">GitHub - segmentio/kafka-go: Kafka library in Go</a></li><li><a href="https://aws.amazon.com/msk/">Managed Kafka - Amazon Managed Streaming for Apache Kafka (MSK) - AWS</a></li><li><a href="https://kafka.apache.org/">Apache Kafka</a></li><li><a href="https://www.confluent.io/what-is-apache-kafka/">What is Apache Kafka? | Confluent</a></li><li><a href="https://medium.com/inspiredbrilliance/kafka-basics-and-core-concepts-5fd7a68c3193">Kafka Basics and Core concepts</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3824a613e40" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/kafka-aws-msk-with-golang-b3824a613e40">Kafka (AWS MSK) with Golang</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Fixed] X509: Certificate Signed by Unknown Authority( Running a docker application on an AWS Ec2…]]></title>
            <link>https://chetan177.medium.com/fixed-x509-certificate-signed-by-unknown-authority-running-a-docker-application-on-an-aws-ec2-f7ddfacefd09?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7ddfacefd09</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[x509]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 08:56:42 GMT</pubDate>
            <atom:updated>2021-12-27T08:56:42.732Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Fixed] X509: Certificate Signed by Unknown Authority( Running a docker application on an AWS Ec2 instance)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*ltk5eGDjLVH7bHiGGCHzpA.png" /></figure><blockquote>Recently while working with docker on AWS Ec2, I have faced the issue of <strong>X509: Certificate Signed by Unknown Authority</strong></blockquote><p>My application is written in Golang and uses multiple AWS services using the Ec2 role-based-access. But while running inside the docker application is unable to access any of the AWS services.</p><p>This is might be due to the case that AWS Services only allow access to AWS signed certificates when using the EC2 role-based-access.</p><p>I have fixed it by using the Ec2 Certificates with the Docker Container. I am using Debian EC2 and debian:bullseye-slimdocker.</p><blockquote><strong>To fix this issue do the followings</strong></blockquote><ul><li>Add this command in your docker file</li></ul><pre><em>RUN apt-get </em>update \<br> <em>&amp;&amp; apt-get </em>install <em>-</em>y <em>--</em>force-yes <em>--</em>no-install-recommends apt-transport-https curl ca-certificates \<br> <em>&amp;&amp; apt-get </em>clean \<br> <em>&amp;&amp; apt-get </em>autoremove \<br> <em>&amp;&amp; rm -</em>rf <em>/</em>var<em>/</em>lib<em>/</em>apt<em>/</em>lists<em>/* </em>\</pre><ul><li>Build docker</li><li>While running the docker image add --mount like the following:</li></ul><pre>docker run -d --mount<br>type=bind,source=/etc/ssl/certs,target=/etc/ssl/certs my-app:latest</pre><blockquote>Mount path may differ based on your Ec2 Linux distribution and Docker image, So paths for the popular distributions are as follows:</blockquote><pre>&quot;/etc/ssl/certs/&quot;,                      // Debian/Ubuntu/Gentoo etc.<br>&quot;/etc/pki/tls/certs/&quot;,                  // Fedora/RHEL 6<br>&quot;/etc/ssl/&quot;,                            // OpenSUSE<br>&quot;/etc/pki/tls/&quot;,                        // OpenELEC<br>&quot;/etc/pki/ca-trust/extracted/pem/&quot;,     // CentOS/RHEL 7<br>&quot;/etc/ssl/&quot;,                            // Alpine Linux</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7ddfacefd09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Freeswitch Configurations Files]]></title>
            <link>https://chetan177.medium.com/freeswitch-configurations-files-6599100da3b1?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6599100da3b1</guid>
            <category><![CDATA[freeswitch]]></category>
            <category><![CDATA[voip]]></category>
            <category><![CDATA[freeswitch-solution]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Thu, 02 Sep 2021 12:50:00 GMT</pubDate>
            <atom:updated>2021-09-02T12:50:00.279Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously we have successfully installed the Freeswitch. In this blog/tutorial we will learn about Freeswitch configurations, the conf directory structure, and the meaning of different files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*p2Qk3rHaNcl5nkvX.gif" /><figcaption>config gif</figcaption></figure><blockquote>Freeswitch stores all its configuration in the conf folder (/usr/local/freeswitch/conf)</blockquote><p>All the Freeswitch XML files for configuration. By, default Freeswitch installs the vanilla configuration for all the modules with minimal settings enable and a lot of comments about each variable.</p><p>Let&#39;s have a look at the directory structure of the conf folder</p><pre>conf/<br>├── autoload_configs # config which loads at startup (core configs)<br>├── chatplan # chatplan for different extensions<br>├── dialplan # dialplan for different extensions<br>├── directory # sip extension user config with grouping<br>├── ivr_menus # ivr menu config directory<br>├── jingle_profiles # jingle configuration (XMPP integration)<br>├── lang # language configs for tts and sound files<br>├── mrcp_profiles # unimrcp config dirrectory<br>├── sip_profiles # sofia sip profile configurations<br>└── skinny_profiles # SCCP config dirrectory</pre><p>Conf folder also contains some config files lets talk about them before diving into the config folders.</p><p>List of files in the config directory:</p><pre>conf<br>├── extensions.conf<br>├── freeswitch.xml <br>├── fur_elise.ttml<br>├── mime.types<br>├── notify-voicemail.tpl<br>├── tetris.ttml<br>├── vars.xml<br>├── voicemail.tpl<br>└── web-vm.tpl</pre><ul><li><strong>freeswitch.xml: </strong>Main configuration file for Freeswitch, on startup Freeswitch, read this file and load the corresponding config specified in it.</li><li><strong>vars.xml: </strong>This file contains all the variables and constants which are used in the other config files. You can define custom variables here and consume them.</li><li><strong>mime.types: </strong>Contains mime-types which are used in Freeswitch.</li><li><strong>fur_elise.ttml, tetris.ttml: </strong>Contains sequences of tones used by Freeswitch.</li><li><strong>notify-voicemail.tpl, voicemail.tpl: </strong>Template for voicemail emails.</li><li><strong>extensions.conf: </strong>Same config as used in asterisk for the extensions. This is used by mod_dialplan_asterisk</li><li><strong>web-vm.tpl: </strong>HTML template to show voicemail on web page.</li></ul><p><strong>Links: <br></strong><a href="https://freeswitch.org/confluence/display/FREESWITCH/Configuration">https://freeswitch.org/confluence/display/FREESWITCH/Configuration</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6599100da3b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Freeswitch on ubuntu.]]></title>
            <link>https://chetan177.medium.com/installing-freeswitch-on-ubuntu-aa26636fae7f?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa26636fae7f</guid>
            <category><![CDATA[freeswitch-development]]></category>
            <category><![CDATA[voip-telephone-system]]></category>
            <category><![CDATA[freeswitch]]></category>
            <category><![CDATA[voip]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 16:02:25 GMT</pubDate>
            <atom:updated>2021-08-22T16:02:51.884Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog/tutorial we will learn how to install Freeswitch on an Ubuntu virtual machine. The steps for Freeswitch installation will be almost the same for the supported OS. So let&#39;s get your hand dirty.</p><blockquote>Note: You can use any VM, a dedicated machine, or any cloud service(AWS, GCP, Azure). I will be using ubuntu 21.04 running on a Vmware workstation with base OS Windows 10.</blockquote><p>You can use the precompiled package but compiling from source provides full control over the Freeswitch.</p><blockquote>Freeswitch source code is available at Github <a href="https://github.com/signalwire/freeswitch">signalwire/freeswitch</a></blockquote><h4>Source code overview</h4><p>Freeswitch is written in C/C++ and uses cmake for compilation. We will go step by step and compile Freeswitch on our machine</p><ul><li>Download source code from Github.</li></ul><pre># make sure you are logged in as a root user.</pre><pre>cd /usr/local/src</pre><pre># clone source code and checkout branch v1.10  <br>git clone -b v1.10 <a href="https://github.com/signalwire/freeswitch.git">https://github.com/signalwire/freeswitch.git</a></pre><ul><li>Freeswitch source code structure</li></ul><pre>freeswitch/<br>├── build # contains build files<br>├── clients # contains client scripts<br>├── cmake_modules # contains some cmake module<br>├── conf # contains default configuration and other conf files<br>├── debian # contains debian related files<br>├── docker # contains docker file<br>├── docs # documentation folder<br>├── dtd # contains dtd files<br>├── fonts # contains fonts file<br>├── fscomm # contains some tools<br>├── htdocs # contains html docs<br>├── images # contains images<br>├── libs # contains external libraries<br>├── scripts # contains scripts<br>├── src # contains main source code of freeswitch <br>├── support-d # contains file related to support<br>├── tests # contains test cases<br>├── w32 # contains file related to windows build<br>├── web # empty now<br>└── yum # contains files for yum pkg manager</pre><blockquote>Note: Terminal might seem to go crazy with logging so have patience don&#39;t close the terminal or try to terminate it.</blockquote><h4>Let&#39;s install Freeswitch:</h4><ul><li>Install FreeSWITCH dependencies</li></ul><pre>apt-get update &amp;&amp; apt-get install -yq gnupg2 wget lsb-release</pre><pre>wget -O - <a href="https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc">https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc</a> | apt-key add -<br> <br>echo &quot;deb <a href="http://files.freeswitch.org/repo/deb/debian-release/">http://files.freeswitch.org/repo/deb/debian-release/</a> `lsb_release -sc` main&quot; &gt; /etc/apt/sources.list.d/freeswitch.list</pre><pre>echo &quot;deb-src <a href="http://files.freeswitch.org/repo/deb/debian-release/">http://files.freeswitch.org/repo/deb/debian-release/</a> `lsb_release -sc` main&quot; &gt;&gt; /etc/apt/sources.list.d/freeswitch.list</pre><pre>apt-get update</pre><pre>apt-get build-dep freeswitch</pre><ul><li>Now sofia-sip and spandsp are not part of the Freeswitch source code so we have to compile them as well.</li></ul><pre>cd /usr/local/src # our source code directory </pre><pre>git clone -b master <a href="https://github.com/freeswitch/spandsp.git">https://github.com/freeswitch/spandsp.git</a></pre><pre>git clone -b master <a href="https://github.com/freeswitch/sofia-sip.git">https://github.com/freeswitch/sofia-sip.git</a></pre><pre># copy them to the freeswitch directories<br>cp /usr/local/src/spandsp /usr/local/src/freeswitch/libs/spandsp -r </pre><pre>cp /usr/local/src/sofia-sip /usr/local/src/freeswitch/libs/sofia-sip -r</pre><pre># compile modsofia and spandsp<br>cd /usr/local/src/freeswitch/libs/spandsp<br>./bootstrap.sh &amp;&amp;./configure &amp;&amp; make &amp;&amp; make install</pre><pre>cd /usr/local/src/freeswitch/libs/sofia-sip<br>./bootstrap.sh &amp;&amp; ./configure &amp;&amp; make &amp;&amp; make install</pre><ul><li>Now let&#39;s compile Freeswitch</li></ul><pre>cd /usr/local/src/freeswitch</pre><pre># initialize dependencies linking</pre><pre>./bootstrap.sh -j</pre><pre># generate make files of all the modules, check for missing <br>dependencies and setup directory structure</pre><pre>./configure </pre><pre># compile freeswitch(this command compiles core and all other modules)</pre><pre>make</pre><pre># copy compile freeswitch binaries to /usr/local/freeswitch</pre><pre>make install</pre><blockquote>Note: We have compiled Freeswitch with the default configuration so some modules might not be available with Freeswitch binaries. Refer to this file to check which modules are compiled <strong>/usr/local/src/freeswitch/modules.conf</strong> all the commented modules are ignored by default during compilation.</blockquote><p><strong>Compilation error example:</strong></p><p>If you get any error during the compilation(make). Please check the logs and install the required dependency. For example:</p><pre># libpq-dev pkg is not installed</pre><pre>making all mod_pgsql<br>make[4]: Entering directory &#39;/usr/local/src/freeswitch/src/mod/databases/mod_pgsql&#39;<br>Makefile:956: *** You must install libpq-dev to build mod_pgsql.  Stop.<br>make[4]: Leaving directory &#39;/usr/local/src/freeswitch/src/mod/databases/mod_pgsql&#39;<br>make[3]: *** [Makefile:712: mod_pgsql-all] Error 1<br>make[3]: Leaving directory &#39;/usr/local/src/freeswitch/src/mod&#39;<br>make[2]: *** [Makefile:613: all-recursive] Error 1<br>make[2]: Leaving directory &#39;/usr/local/src/freeswitch/src&#39;<br>make[1]: *** [Makefile:3680: all-recursive] Error 1<br>make[1]: Leaving directory &#39;/usr/local/src/freeswitch&#39;<br>make: *** [Makefile:1432: all] Error </pre><p>We can clearly see the error log which specifies the required dependency (<em>Makefile:956: *** You must install libpq-dev to build mod_pgsql. Stop.</em>)for this case is libpg-dev. We can fix this by simply installing it.</p><pre># Fix<br>apt-get install libpq-dev</pre><p>Now run commands from bootstrap again</p><p>If you can&#39;t find a package using apt or yum please try to google it and resolve it.</p><p>You will see the following message when Freeswitch is installed successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*QRR2SBieRwzrG5g2AAQNeA.png" /><figcaption>success</figcaption></figure><ul><li>If you want to install Freeswitch sound use these commands. (~2GB download)</li></ul><h4>Freeswitch compiled directory structure</h4><p>Compiled FreeSWITCH will be available at (/usr/local/freeswitch) directory structure of compiled Freeswitch is as follows:</p><pre><br>      exec_prefix:     /usr/local/freeswitch<br>      bindir:          ${exec_prefix}/bin<br>      confdir:         /usr/local/freeswitch/conf<br>      libdir:          ${exec_prefix}/lib<br>      datadir:         /usr/local/freeswitch<br>      localstatedir:   /usr/local/freeswitch<br>      includedir:      /usr/local/freeswitch/include/freeswitch</pre><pre>      certsdir:        /usr/local/freeswitch/certs<br>      dbdir:           /usr/local/freeswitch/db<br>      grammardir:      /usr/local/freeswitch/grammar<br>      htdocsdir:       /usr/local/freeswitch/htdocs<br>      fontsdir:        /usr/local/freeswitch/fonts<br>      logfiledir:      /usr/local/freeswitch/log<br>      modulesdir:      /usr/local/freeswitch/mod<br>      pkgconfigdir:    ${exec_prefix}/lib/pkgconfig<br>      recordingsdir:   /usr/local/freeswitch/recordings<br>      imagesdir:       /usr/local/freeswitch/images<br>      runtimedir:      /usr/local/freeswitch/run<br>      scriptdir:       /usr/local/freeswitch/scripts<br>      soundsdir:       /usr/local/freeswitch/sounds<br>      storagedir:      /usr/local/freeswitch/storage<br>      cachedir:        /usr/local/freeswitch/cache</pre><h4>Start Freeswitch:</h4><p>Freeswitch binaries are available in this directory <em>/usr/local/freeswitch/bin. </em>Execute Freeswitch binary now.</p><pre><em>/usr/local/freeswitch/bin/freeswitch -nc</em></pre><pre># here -nc flag means run in background</pre><p>Connect Freeswitch using fs_cli.</p><pre><em>/usr/local/freeswitch/bin/fs_cli -r</em></pre><pre># here -r flag mean try to reconnect</pre><p>Freeswitch CLI (fs_cli) connects with the Freeswitch using the ESL</p><p>You will see this screen after a successful start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFSp78M23CadqAoIVN1p3Q.png" /></figure><p>Type version in the fs_cli to check Freeswitch version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*EUlpaTMA2zkIoGARyzd96w.png" /><figcaption>version</figcaption></figure><p>Type /exit to close from fs_cli.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*B2oQDzZA3QSOvSsciKny8w.png" /></figure><p>We will learn more about how to use fs_cli and Freeswitch configuration in the upcoming blogs.</p><p><strong>Links:</strong></p><ul><li><a href="https://github.com/signalwire/freeswitch">GitHub - signalwire/freeswitch: FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.</a></li><li><a href="https://github.com/freeswitch/sofia-sip">GitHub - freeswitch/sofia-sip: Sofia-SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.</a></li><li><a href="https://github.com/freeswitch/spandsp">GitHub - freeswitch/spandsp: SpanDSP is a low-level signal processing library that modulates and demodulates signals commonly used in telephony, such as the &quot;noise&quot; generated by a fax modem or DTMF touchpad.</a></li><li><a href="https://freeswitch.org/confluence/display/FREESWITCH/Installation">Installation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa26636fae7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Freeswitch?]]></title>
            <link>https://chetan177.medium.com/what-is-freeswitch-8d7e973cf758?source=rss-41a2ab1737f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d7e973cf758</guid>
            <category><![CDATA[voip]]></category>
            <category><![CDATA[sip]]></category>
            <category><![CDATA[freeswitch-software]]></category>
            <category><![CDATA[voice-over-ip]]></category>
            <category><![CDATA[freeswitch]]></category>
            <dc:creator><![CDATA[Chetan Pandey]]></dc:creator>
            <pubDate>Sat, 21 Aug 2021 20:19:35 GMT</pubDate>
            <atom:updated>2021-08-21T20:24:37.894Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are working in VOIP / Telecom domain you might have heard and worked on software likes Asterisk, Opensips, Kamailio, etc. All these are used to develop and build VOIP services and are heavily used in the telecommunication domain. If we look at some voice/video chat applications like Skype, Zoom, WhatsApp, Viber they all use some sort of VoIP stack in the backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8b7vg8rEUs5au0b2FSfTMw.png" /><figcaption>Freeswitch</figcaption></figure><blockquote>Freeswitch is a software that provides a fully configurable and customizable telecom stack for modern application</blockquote><p>Freeswitch is open-source software that provides a production-grade telecom stack that has many applications like PBX, CallCenter Application, Sip Proxy, RTP Proxy, Audio / Video conference, etc.</p><blockquote>As you are reading this blog Freeswitch running on cloud is serving many applications and people are using it to build complex modern telecommunication systems.</blockquote><p>Freeswitch is so widely used because of the features and customization it offers.</p><h4><strong>Features:</strong></h4><ul><li>Freeswitch support VoIP, WebRTC and PSTN</li><li>Freeswitch can run on a single core VM to a 32-core full dedicated server. It also supports a wide range of operating systems Linux, OsX, BSD, Solaris, and even windows.</li><li>Freeswitch has full encryption support ZRTP, DTLS, SIPS, WSS</li><li>Freeswitch has the support of a wide range of audio codecs like G722, PCMU, PCMA, Opus, Speex, AMR, GSM, VP8, VP9</li><li>Freeswitch has a lot of inbuilt modules which can be used in multiple use cases. For example mod_conference for video and audio conferencing.</li><li>Freeswitch is fully customizable you can use 3rd party open source modules or write your module. All modules are plug and play. It also supports a hot reload of modules.</li><li>Freeswitch also supports SMPP (SMS).</li><li>There is CLI support using fs_cli which gives access to a large number of commands executed on ESL.</li><li>Freeswitch also supports automatic speech recognition and text-to-speech features using ASR and TTS modules.</li></ul><h3>Freeswitch Architecture:</h3><p>Freeswitch is written in C/C++ and has a modular architecture. There is <strong>Core</strong> that provides a base system that is used by all the modules. Core doesn&#39;t have many functionalities most of the features are achieved by stand-alone modules. This modular design makes Freeswitch fully customizable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0O-fl62aHgSoUlGtIsKGrw.png" /><figcaption>Freeswitch architecture</figcaption></figure><p><strong>Freeswitch modules and their brief description.</strong></p><p><strong>Endpoint: </strong>Telephone protocols like WebRTC, SIP/H.323, and POTS lines</p><p><strong>Application: </strong>Performs a task such as playing audio or setting data</p><p><strong>Application Programming Interface (API): </strong>Exports a function that takes text input and returns text output, which could be used across modules or from an external connection</p><p><strong>Automated Speech Recognition (ASR): </strong>Interfaces with speech recognition systems</p><p><strong>Chat: </strong>Bridges and exchanges various chat protocols</p><p><strong>Codec: </strong>Translates between audio formats</p><p><strong>Dialplan: </strong>Parses the call details and decides where to route the call</p><p><strong>Directory: </strong>Connects directory information services, such as LDAP, to a common core lookup API</p><p><strong>Event handlers: </strong>Allows external programs to control FreeSWITCH</p><p><strong>File: </strong>Provides an interface to extract and play sound from various audio file formats</p><p><strong>Formats: </strong>Plays audio files in various formats</p><p><strong>Languages: </strong>Programming language interfaces used for call control</p><p><strong>Loggers: </strong>Controls logging to the console, system log, or log files</p><p><strong>Text-To-Speech (TTS): </strong>Interfaces with text-to-speech engines</p><p><strong>Timers: </strong>POSIX or Linux kernel timing in applications</p><p><strong>XML Interfaces: </strong>Uses XML for Call Detail Records (CDRs), RADIUS, CURL, LDAP, RPC, and/or SCGI</p><p>Freeswitch provides a whole lot of modules with its package we will explore them in the upcoming blogs.</p><h3><strong>Who uses Freeswitch:</strong></h3><p>Freeswitch is <strong>Extensible, Scalable, Flexible, </strong>and <strong>Stable</strong> that&#39;s why it is used by industry-leading organizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wm_zDJtbKf_FClIYwmj5pA.png" /><figcaption>signal wire</figcaption></figure><p>And a lot of organizations are also using Freeswitch to provide Communication as a Service (CAAS)</p><blockquote>NOTE: There are many abbreviations and terms which may be unknown to someone who is new to the telecommunication domain, so don’t get confused a simple google search for these terms will clear their meaning.</blockquote><p><strong>Links:</strong></p><p>Freeswitch docs: <a href="https://freeswitch.org/confluence/">https://freeswitch.org/confluence/</a></p><p>Freeswitch Github: <a href="https://github.com/signalwire/freeswitch/">https://github.com/signalwire/freeswitch/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d7e973cf758" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>