<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saransh Barua</title>
    <description>The latest articles on DEV Community by Saransh Barua (@_saranshbarua).</description>
    <link>https://dev.to/_saranshbarua</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F126352%2F5c9b22de-b3ab-4f48-bd23-0fa1f67dfe84.jpg</url>
      <title>DEV Community: Saransh Barua</title>
      <link>https://dev.to/_saranshbarua</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_saranshbarua"/>
    <language>en</language>
    <item>
      <title>WebSocket Close Codes Explained: A guide to Connection Status Codes</title>
      <dc:creator>Saransh Barua</dc:creator>
      <pubDate>Thu, 03 Apr 2025 06:55:37 +0000</pubDate>
      <link>https://dev.to/_saranshbarua/websocket-close-codes-explained-a-guide-to-connection-status-codes-5cmd</link>
      <guid>https://dev.to/_saranshbarua/websocket-close-codes-explained-a-guide-to-connection-status-codes-5cmd</guid>
      <description>&lt;p&gt;WebSocket connections, unlike traditional HTTP requests, maintain a persistent connection between client and server. When these connections end, they do so with specific close codes that provide valuable information about why the connection was terminated. Let's dive into these codes and understand their significance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Normal Closure Scenarios (1000-1001)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1000 - Normal Closure
&lt;/h3&gt;

&lt;p&gt;This is the "happy path" of WebSocket closures. When you see this code, it means the connection completed its purpose and was closed gracefully. Think of it like hanging up a phone call after saying goodbye.&lt;/p&gt;

&lt;h3&gt;
  
  
  1001 - Going Away
&lt;/h3&gt;

&lt;p&gt;The server or client is going down for maintenance or a browser tab is closing. It's like telling your friend "I need to go now" before ending a conversation. This gives the other party a chance to prepare for disconnection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protocol and Data Issues (1002-1003)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1002 - Protocol Error
&lt;/h3&gt;

&lt;p&gt;Something went wrong with the WebSocket protocol itself. It's similar to two people speaking different languages - communication becomes impossible.&lt;/p&gt;

&lt;h3&gt;
  
  
  1003 - Unsupported Data
&lt;/h3&gt;

&lt;p&gt;The endpoint received data it couldn't handle. Imagine sending an image file when the receiver only expects text messages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connection Abnormalities (1005-1006)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1005 - No Status Received
&lt;/h3&gt;

&lt;p&gt;A connection closed without explicitly stating why. This is like someone hanging up the phone without saying anything.&lt;/p&gt;

&lt;h3&gt;
  
  
  1006 - Abnormal Closure
&lt;/h3&gt;

&lt;p&gt;The connection was terminated unexpectedly. Think of it as your phone call dropping due to poor signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data and Policy Issues (1007-1009)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1007 - Invalid Frame Payload
&lt;/h3&gt;

&lt;p&gt;The message contained invalid data. It's like receiving a corrupted file.&lt;/p&gt;

&lt;h3&gt;
  
  
  1008 - Policy Violation
&lt;/h3&gt;

&lt;p&gt;The endpoint is terminating the connection due to a policy breach. Similar to being removed from a chat room for violating rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  1009 - Message Too Big
&lt;/h3&gt;

&lt;p&gt;The message exceeded size limits. Like trying to send a file that's too large via email.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Issues (1010-1015)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1010 - Mandatory Extension
&lt;/h3&gt;

&lt;p&gt;The client wanted an extension the server couldn't provide. Think of it as needing a specific app feature that isn't available.&lt;/p&gt;

&lt;h3&gt;
  
  
  1011 - Internal Server Error
&lt;/h3&gt;

&lt;p&gt;Something went wrong on the server side. Similar to a restaurant kitchen having problems preparing your order.&lt;/p&gt;

&lt;h3&gt;
  
  
  1012 - Service Restart
&lt;/h3&gt;

&lt;p&gt;The service is restarting. Like a "be right back" sign in a shop window.&lt;/p&gt;

&lt;h3&gt;
  
  
  1013 - Try Again Later
&lt;/h3&gt;

&lt;p&gt;The server is temporarily unable to handle the request. Think of it as a "busy signal" on a phone line.&lt;/p&gt;

&lt;h3&gt;
  
  
  1015 - TLS Handshake Failure
&lt;/h3&gt;

&lt;p&gt;There was a problem with the security handshake. Similar to failing to verify someone's identity before a secure conversation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Handling Close Codes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always implement handlers for at least codes 1000, 1001, and 1006&lt;/li&gt;
&lt;li&gt;Log abnormal closures (especially 1006 and 1011)&lt;/li&gt;
&lt;li&gt;Provide reconnection logic for temporary issues (1012, 1013)&lt;/li&gt;
&lt;li&gt;Give user feedback for policy violations (1008)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>websockets</category>
    </item>
    <item>
      <title>Creating a smooth landing page reveal animation with CSS animations and vanilla JS</title>
      <dc:creator>Saransh Barua</dc:creator>
      <pubDate>Mon, 06 Jul 2020 18:46:32 +0000</pubDate>
      <link>https://dev.to/_saranshbarua/creating-a-simple-yet-smooth-reveal-animation-with-the-swiss-knife-css-animations-vanillajs-on-codepen-4mc1</link>
      <guid>https://dev.to/_saranshbarua/creating-a-simple-yet-smooth-reveal-animation-with-the-swiss-knife-css-animations-vanillajs-on-codepen-4mc1</guid>
      <description>&lt;p&gt;This is my first post on Dev, so I will keep it simple and short. Recently I came back to Codepen after years to do what I love the most - create awesome stuff(at least I try to). &lt;br&gt;
And this time I decided to put the big guns (react, vue, webgl, etc) aside and use the ultimate old school swiss knife (html, CSS, JavaScript) to create something. &lt;br&gt;
Animations and interactions attract me the most when I visit a website or a product. Hence I tried to create a small animation and I had two things in mind:&lt;br&gt;
• Can I create something which does not require a lot of complex code or use of a library?&lt;br&gt;
• Despite being simple it should offer delightful user experience and should be smooth!&lt;/p&gt;

&lt;p&gt;I came up with this:&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/saranshbarua/embed/WNrMbxJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  The idea
&lt;/h3&gt;

&lt;p&gt;The concept behind the text reveal animation is dead simple.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Put some text in it.&lt;/li&gt;
&lt;li&gt;Apply &lt;code&gt;overflow: hidden&lt;/code&gt; on the div so that anything outside the box is not visible.&lt;/li&gt;
&lt;li&gt;Move the text downwards and rotate it a by a few degrees using &lt;code&gt;transform: translateY(200px) rotate(15deg)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Now the text is hidden because it is outside the box and tilted a little bit.&lt;/li&gt;
&lt;li&gt;Create a CSS animation using @keyframes - Move the text upwards by 200px and rotate it to 0 deg by the end of the animation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;slideup&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;20deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;7.Now comes the fun part where you need to set the animation duration and other attributes as well as bezier curve for the animation. These attributes combined are the key to make a good animation. &lt;br&gt;
I choose easeInOutCubic(0.65, 0, 0.35, 1) because it resembles the flow that I wanted in my animation. You can choose some other values depending on what you like and how you want your animation to look and feel like. Here's the class that enables the animation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.animate-slideup&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;15deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;slideup&lt;/span&gt; &lt;span class="m"&gt;1000ms&lt;/span&gt; &lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.65&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="n"&gt;forwards&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;top&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Notice how initially the text is shifted 200px downwards in Y direction.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is it. This is the css used to create that effect where the text slides up with a slight rotation. But it still does not feel good. Why?&lt;/p&gt;

&lt;p&gt;It's because right now, we are animating the whole text at once. What we want is that the words flow up slowly and individually so that the animation seemsa bit more interesting.&lt;br&gt;
To achieve that, we use some javascript magic ;)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We create a quote string.&lt;/li&gt;
&lt;li&gt;Traverse that string and on each word, create a span using &lt;code&gt;document.createElement("span")&lt;/code&gt;. Attach the class &lt;code&gt;animate-slideup&lt;/code&gt; to that span and append this child to the parent . Also, we need to add an animation-delay on every traversal with the delay increasing at a constant rate on every iteration. Something like &lt;code&gt;delay(in ms) = delay(in ms) + x(const)&lt;/code&gt;.


&lt;p&gt;Congratulations!! This is it. This gives you the animation that you've been craving for. The flow that you couldn't get out of your head while you were trying to sleep. And god, you feel so great now!&lt;/p&gt;
&lt;h3&gt;
  
  
  Extra efforts
&lt;/h3&gt;

&lt;p&gt;I added some extra animations(CSS only) which will reveal our hero text and our main animations. The code for that is simple too. Grow the width of a div till 50% of the time and then height from 2px to 100vh till 100% of the time. (in this case the light green background), render the main animation and at last a sweet rotating effect for the full stop to give a solid ending to our smooth animation.&lt;/p&gt;
&lt;h3&gt;
  
  
  Parting words
&lt;/h3&gt;

&lt;p&gt;I failed at keeping this post short but I hope I made it simple. This is my first blog/post on any platform that I've written. I hope you enjoyed it! Let me know in the comments.&lt;/p&gt;

&lt;p&gt;You can follow me and get in touch with me on various social media accounts. I would love to talk to you, listen to your stories and experiences and help you out in any way possible!&lt;br&gt;
• &lt;a href="https://twitter.com/_saranshbarua"&gt;Twitter&lt;/a&gt; &lt;br&gt;
• &lt;a href="https://codepen.io/saranshbarua"&gt;Codepen&lt;/a&gt; &lt;br&gt;
• &lt;a href="https://github.com/saranshbarua"&gt;Github&lt;/a&gt;&lt;br&gt;
• &lt;a href="https://www.linkedin.com/in/saranshbarua"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And lastly, remember, try to keep it simple because &lt;strong&gt;&lt;em&gt;Simple is the new sexy!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>codepen</category>
      <category>css</category>
      <category>showdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
