<?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 Bjorn Sayers on Medium]]></title>
        <description><![CDATA[Stories by Bjorn Sayers on Medium]]></description>
        <link>https://medium.com/@bjornsayers?source=rss-3e4dc881a5ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tUGZ1dD1KIz0aIiZ.</url>
            <title>Stories by Bjorn Sayers on Medium</title>
            <link>https://medium.com/@bjornsayers?source=rss-3e4dc881a5ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:35:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bjornsayers/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[Working with people who are smart(er than you)]]></title>
            <link>https://medium.com/remesh/working-with-people-who-are-smart-er-than-you-d89eb1ad4777?source=rss-3e4dc881a5ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/d89eb1ad4777</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[smart-people]]></category>
            <dc:creator><![CDATA[Bjorn Sayers]]></dc:creator>
            <pubDate>Mon, 26 Oct 2020 12:02:31 GMT</pubDate>
            <atom:updated>2020-10-26T12:02:31.618Z</atom:updated>
            <content:encoded><![CDATA[<p>Working at Remesh, I have the pleasure of working with some really smart, nice, great people. I consider myself one of these smart, nice, people. I don’t know if I’d go as far as great, but I do consider myself a decent person. In what follows I’m going to set aside the “nice” and the “great” parts and focus on the “smart” part. This isn’t to say that I don’t care about people being nice and great (sub in your own definition of great here) or that it doesn’t matter. I do care, and it does matter. Not only do I find working with nice people to be more enjoyable, I also believe that, in most cases, it enables greater productivity.</p><p>I focus on “smart” here because there’s a few things about working with smart people that I have learned that I’d like to share. In particular, I focus on instances where I’ve disagreed with someone smarter than me. I start by sketching out some thoughts on what it means to be smart and smarter. Then I put forward a general pattern of such disagreements. Lastly, I walk through three ideas that I have found helpful in managing, understanding and working through such situations.</p><p>Let me start by putting forward a rough idea of what I have in mind by “smart” and “smarter.” To be clear, I do not intend to give an all-encompassing definition or put forward some definitive view of what it means to be smart. Instead, I aim to give enough to detail to make sense of the pattern that follows and the ideas I present alongside it. As such, for my purposes someone who is “smart” is someone who both:</p><ol><li>Knows quite a bit, especially about some particular area like software engineering, Python, or machine learning</li><li>Learns and understands new information rapidly, again especially in a particular area like machine learning etc.</li></ol><p>On this account someone is smarter than someone in general, or on a particular topic X, if they know more about X and they are able to learn about X more rapidly than someone else. Of course there could, and likely are, many cases where person <em>p1</em> meets (a) for a subject like Python and person <em>p2</em> meets (b) for Python. This would be to say that <em>p1 </em>knows more about Python than <em>p2,</em> but <em>p2 </em>learns new things about Python faster than <em>p1</em>. In such cases we can say that each individual is smarter in a particular way.</p><p>There are two final things worth noting about the definition of <em>smart </em>just put forward. First, we often come to know that someone is smarter than us, or someone else, by noticing that they are right about something more often or more frequently. I come to believe that Bill is really smart when it comes to Python because he almost always knows the answer to my questions (what he tells me works, it solves my problem) or, if he doesn’t know the answer, he is able to quickly figure it out. Second, just because Bill is smarter it doesn’t guarantee that he will get the right answer. With all of this in mind I now turn to a generalized pattern of disagreement that I’ve experienced when working with people who are smarter than me.</p><p>The generalized pattern looks like this:</p><p><strong>Team is presented with a problem <em>P</em>:</strong> We need to build a feature that does X or We need to make X faster etc. (The problem scope can be specific, like “allow users to approve new job requests” or general “build a system that does X”)</p><p><strong>Smarter than me Bill: </strong>We should take Approach <em>A</em></p><p><strong>Me, after some thought: </strong>We should take Approach <em>B </em>(where B is mutually exclusive from <em>A</em>)</p><p>I now need, or at least want, to determine which, if either of us, is right. Sometimes it is enough to appeal to the broader team. At Remesh I’ve been blessed to work on teams with multiple smart people, sometimes many or all of whom are smarter than me. If <em>Also Smarter than me Alan </em>says we should take Approach <em>A</em> and the decision is small enough I just get onboard and move on. However, I’ve experienced many a time where either one of the following is true: (a) only Bill and I are deep enough into the problem (or have the required background knowledge etc.) to have a real take on the various approaches, or (b) the broader team is mixed when it comes to the two approaches or lacks strong opinions/points of view. So what do I do in these situations and what have I learned from them?</p><p>The first thing I try to do in these cases of disagreement is figure out if I’m “ahead” or “behind.” Am I the smarter individual who has more knowledge in this domain and more context with respect to problem <em>P</em>,<em> </em>i.e., am I “ahead”? Or, is Bill smarter and the one with more knowledge and context, i.e., am I “behind”? It isn’t always easy or possible to figure out whether you are ahead or behind, but the upshot of doing so is that you get a sense of who is missing information and who is at least more likely to be right (and in turn which approach). If I am ahead, then I would start by focusing on why my Approach <em>B </em>is superior and attempt to figure out what knowledge or information I could share with Bill to get him to see this. If I am behind, I would start by focusing on Approach <em>A </em>and trying to figure out what additional knowledge or information would bring me around to agreeing it is the superior approach.To be sure, the “ahead” or “behind” axis is just one avenue for making progress and it does not exhaust all of the possibilities (it could turn out that through knowledge sharing Bill and I actually settle on a new Approach <em>C</em>). However, it is an that I have found to be effective in many cases and, accordingly, a good place to start.</p><p>The next thing I try to do in these cases is figure out what more specific ideas, thoughts, or propositions are being disagreed about. Obviously Bill and I disagree about whether we should take Approach <em>A</em>, but why exactly do we disagree? Do we have a different set of requirements in mind? Do we disagree about how much time we have to solve the problem or the availability and talents of the individuals who will be solving the problem with us? (As an aside, I have frequently seen individuals smarter than me make the mistake of assuming that others who will help solve the problem are as talented, productive etc. as they are.) Do we have a different understanding about how some language, system, framework, or existing code works? In most, if not all, of these cases, if we can determine what it is that we disagree about we can simply figure out what the right answer is by looking things up, trying things out, or asking others. We can figure out if a framework provides a particular feature. We can go back to stakeholders and ask them whether or not a specific requirement actually holds.</p><p>The last thing that I try to do in these situations is to embrace <em>either </em>being right or wrong and to do it as quickly as possible. For most people being right is easy, however, when you know that Bill is smarter than you it can be more difficult because, by default, you are used to accepting what Bill says on particular topics and you know that historically he is often right. Thus, when working with smarter people I try to quickly figure out if there’s a possibility that I am ahead because I have additional context and, if so, I try to share that information as clearly as possible. At this point in my life I’ve eaten enough humble pie to easily embrace being wrong, but this too can be challenging. It requires you to get over yourself and accept that you make mistakes. It also requires you to learn or understand what it is that Smarter than you Bill knows that you do not.</p><p>In summary, I have put forward some thoughts about working with people who are smarter than me. I began by giving a rough idea of what I have in mind by “smarter than,” which mostly boils down to knowing more about a particular area as indicated by being right more often in said area. I then outlined a general pattern of disagreement I sometimes encounter when working with smart people and some concrete ideas towards quickly and effectively resolving the disagreement. In particular, I suggested the heuristic of “ahead” or “behind” to figure out which approach is worth looking at first. While I do not think this can be used to resolve or explain all disagreements, I do think it is effective in many cases, especially when time is of the essence. Here resolving production issues in real-time comes to mind. Feel free to share some of your own experiences and approaches in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d89eb1ad4777" width="1" height="1" alt=""><hr><p><a href="https://medium.com/remesh/working-with-people-who-are-smart-er-than-you-d89eb1ad4777">Working with people who are smart(er than you)</a> was originally published in <a href="https://medium.com/remesh">Remesh Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launch of Remesh Engineering Youtube Channel]]></title>
            <link>https://medium.com/remesh/launch-of-remesh-engineering-youtube-channel-fc2b99c9f015?source=rss-3e4dc881a5ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc2b99c9f015</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Bjorn Sayers]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 12:01:01 GMT</pubDate>
            <atom:updated>2020-06-15T12:01:01.632Z</atom:updated>
            <content:encoded><![CDATA[<p>Today my fascination with the medium of video continues and takes a step forward with the launch of <a href="https://www.youtube.com/channel/UCPwvu3QmVXYpnYTlBC3WesA?view_as=subscriber">Remesh Engineering’s Youtube Channel</a>. On it you will find various content capturing Engineering events ranging from serious and technical to social and fun. Our aim for the channel is to have a place that captures things we’ve done, who we think we are, and who we’d like to become. Internally, it tracks Remesh Engineering’s history and culture. Externally, it offers those interested a taste of who we are and what we’re up to. We also publish our internal lunch and learns that offer our insight and take on technical topics like testing, debugging in the browser, and using Django migrations. Current Videos:</p><p><strong>Dan Reich Lunch and Learn 3/12/2020 “Tools of the Trade: DevTools for Fools”</strong> — Lead Engineer Dan Reich discusses different tactics for debugging in the browser.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0CE14a0VDFQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0CE14a0VDFQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0CE14a0VDFQ%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/6ae27ec8b06474e695fa1688d93c58ae/href">https://medium.com/media/6ae27ec8b06474e695fa1688d93c58ae/href</a></iframe><p><strong>Chris NeJame Lunch and Learn 12/10/19 “Scientific Testing”</strong> — Engineer Chris NeJame describes what “Scientific Testing” is and how to make tests more reliable and repeatable.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzTZzOmzV8Ww%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzTZzOmzV8Ww&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzTZzOmzV8Ww%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/231e268e72943f31f5ffa4df565f17f7/href">https://medium.com/media/231e268e72943f31f5ffa4df565f17f7/href</a></iframe><p><strong>Dr. Bjorn Sayers Lunch and Learn 10/29/2019 “‘Watch’ and Learn and… Do: Improving our Unit Testing (habits) using ‘watch’ mode”</strong> — Senior Engineer Bjorn Sayers talks about running unit tests in watch mode and how to make doing so part of one’s habits.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKCbYTSOx4Uo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKCbYTSOx4Uo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKCbYTSOx4Uo%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/cda527b47d8b9f72944f44517d28438c/href">https://medium.com/media/cda527b47d8b9f72944f44517d28438c/href</a></iframe><p>Dan becomes the first Remesher to “take a pie”. Admittedly, I’m still searching for the second one.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FvFTSE9cy6_w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvFTSE9cy6_w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FvFTSE9cy6_w%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cae817246b479a514e4f07244c065c20/href">https://medium.com/media/cae817246b479a514e4f07244c065c20/href</a></iframe><p><strong>Will Specht Lunch and Learn 5/12/2020 “Django Migrations”</strong> — Senior Engineer Will Specht discusses tips and tricks for working with Django Migrations. Video Coming Soon!</p><p>Please stay tuned for future content and feel free to let us know what you think.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc2b99c9f015" width="1" height="1" alt=""><hr><p><a href="https://medium.com/remesh/launch-of-remesh-engineering-youtube-channel-fc2b99c9f015">Launch of Remesh Engineering Youtube Channel</a> was originally published in <a href="https://medium.com/remesh">Remesh Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Establishing a long-term connection with websockets: a story about the (ongoing) evolution of my…]]></title>
            <link>https://medium.com/remesh/establishing-a-long-term-connection-with-websockets-a-story-about-the-ongoing-evolution-of-my-1e0747dfbb7e?source=rss-3e4dc881a5ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e0747dfbb7e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mental-models]]></category>
            <category><![CDATA[websocket]]></category>
            <dc:creator><![CDATA[Bjorn Sayers]]></dc:creator>
            <pubDate>Mon, 04 May 2020 18:01:01 GMT</pubDate>
            <atom:updated>2020-05-04T18:01:01.031Z</atom:updated>
            <content:encoded><![CDATA[<h3>Establishing a long-term connection with websockets: a story about the (ongoing) evolution of my browser-server mental model.</h3><p>Mental models are not a dime a dozen. They are not available via mail-order or download. They have to be built, or more precisely, learned. Sometimes they are learned independently through reading and experience. Other times we require discussion and dialogue to tune our ideas and associated models. These learnings usually span days, sometimes weeks and can even go on for months or years. Furthermore, even after mental models are acquired they are almost always subject to update and revision, which can mean that they take even longer to solidify and become effective. Having said all that, there are cases where the right concepts, put forward in the right light, make the process easier and faster. In this article, I take a swing at putting forward the right concepts, in the right light, for developing an effective mental model of WebSockets. At the very least, I stitch together the path I took and the mental model I ended up with. Overall I present the evolution of my mental model of browser-server communication from a single, request-response centered track to a dual-track model that includes a second track for WebSocket communication.</p><p>I start by briefly introducing our recent work at Remesh involving WebSockets. Then, I talk about how a single-track request-response model can get you by for years and what, at a high-level, this understanding of browser-server communication consists of. Next, I tease out in detail three key aspects of browser-server communication: starting and stopping, message content, and error-handling. From here, I turn to WebSockets and show how these aspects apply to them in my recently constructed second track. Then, I look at how these tracks interact or come together. Lastly, I conclude by looking at how Redux Middleware can be used to implement both forms of browser-server communication and organize the set of abstractions (mental models) we’ve introduced. If this sounds like I’m double-dipping, it’s because I am; I think Redux Middleware is a good implementation <em>and </em>provides a helpful abstraction.</p><h3>Websockets at Remesh</h3><p>At Remesh, our platform enables hundreds of participants to engage in a real-time “conversation” with a moderator with the aim of increasing understanding. Many things are done via HTTP requests and polling, but a number of things like conversation messages are sent in real-time via WebSockets. Up until recently we used Apollo Subscriptions to manage our real-time, WebSocket communication. However, due to a number of challenges, we transitioned to managing our own WebSocket communication using GiantMachines<a href="https://github.com/giantmachines/redux-websocket"> redux-websocket</a> library on the frontend and Django<a href="https://channels.readthedocs.io/en/latest/"> channels</a> on the backend.</p><h3>Getting by on a single-track HTTP model</h3><p>As it stood, this was my first time using and implementing a WebSocket-based solution at scale. I had done years of web application development using HTTP and your typical request-response pattern, resorting to polling in a handful of cases where “near” real-time information was needed. It had also been drilled into my head that HTTP request-response was sufficient for 99% (perhaps 95% these days) of use-cases (For one person’s take on whether or not you need WebSockets see <a href="https://blog.stanko.io/do-you-really-need-websockets-343aed40aa9b">this article</a>). Needless to say, my (browser) client-server model was incredibly one-tracked. On this one-track model, when a user goes to a URL, they make a request and are served a page (response). When the user takes an action — clicks a tab, scrolls the page, opens a modal — a request is made and a response with the new content is delivered. In this model, the server is passive and different responses can be identified by different URLs (including the path and query parameters) and responded to accordingly. In extreme cases where the user needs more real-time information, I turned up the only knob available to me — the frequency of requests. For a chat-like, real-time conversation application like ours at Remesh this just doesn’t cut it: participants must get their messages immediately. Enter WebSockets and my need to get familiar with them.</p><h3>Three concepts of client-server communication</h3><p>Before taking a closer look at WebSockets, I want to make three aspects of browser-server communication explicit:</p><ol><li>Starting and stopping: How does communication start and stop?</li><li>Message content: How do I know what’s in my messages? How do I know what they “mean” and what to do with them?</li><li>Error handling: What can go wrong? What if anything can I do about it?</li></ol><p>At the end of the day, browser-server communication is an exchange of information between two entities. We structure this exchange with different protocols, two of which are HTTP and WebSocket.</p><p>Let’s look at how these three aspects apply to HTTP in some detail. With HTTP, starting and stopping is captured by the request-response cycle. Communication starts when a request is issued and it stops when a response is received. There’s nothing much complicated about it, and you always receive a response (of some sort) to your request. Message content is a topic unto itself, as there have been many solutions to this problem: RMI, CORBA, SOAP, and JSON among others, but what matters for our purposes is that for a lot of HTTP communication we know what sorts of responses we are likely to receive and the meaning of their content based on the URL that we call. Below, we will see how this differs when it comes to WebSockets, where we receive multiple types of messages from the same source. Lastly, there are a lot of things that can<em> </em>go wrong with HTTP communication (<a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">see 4xx and 5xx on wikipedia</a>), but in general, these fall into one of two buckets. One bucket, 4xx, captures issues with the browser request — wrong format, size, not authorized etc. The other bucket, 5xx, captures issues that occurred on the server — unexpected error, unexpected load, etc. Sometimes we want to report these errors back to the end-user, especially in cases where there is something they can do about the error, like updating previously invalid input. In sum, HTTP communication occurs in a request-response cycle, where we often know the nature of the response based on the target of the request. Furthermore, things can go wrong in two broad ways at the request-response level. In some cases we report these errors back so that they can be acted upon.</p><h3>Applying these concepts to WebSockets</h3><p>Let’s now see how the three aspects of browser-server communication above apply to WebSockets. First, starting and stopping is slightly different because we typically start one (or more) long-standing WebSocket connections with the server. In fact, it is their long-standing, always ready, nature that make WebSockets more appealing for use-cases involving real-time data. Once a “long-standing” WebSocket connection has been established, both the browser and the server can send messages. At Remesh, this allows us to push messages directly to the client, effectively eliminating half of the HTTP request-response cycle. Of course, along these lines, in contrast to HTTP, the content of these messages is not differentiated by the URL or target of the response because all messages on both sides are coming from a single source or origin. As such, messages must convey their type so that recipients know how to handle them. This requirement can be met by simply supplying the type information as part of the message content. Lastly, error-handling for WebSockets is slightly different than HTTP. One has to handle the case where a connection can not be established as well as the case where an existing connection is interrupted. One must also be mindful that in the latter case of connection interruption the browser and the server may have gotten out of sync due to “missed” messages. On the Remesh platform, participants receive actual messages for their conversation in real-time via WebSockets, so if a connection is interrupted, we need to make sure the participant is “caught up,” i.e. they receive messages that were lost during the interruption. All in all, one can see that websockets are different, but similar, to HTTP communication.</p><h3>Putting the tracks together with some abstractions from Redux</h3><p>So how do the two tracks fit together? To be honest, while I was initially fixated on the “relationship between” WebSockets and HTTP and which one came prior, or was really in control, at the end of the day there is little if anything interesting to say here. HTTP and WebSockets are two independent types of communication that you can use from the browser to meet various use cases. There is no need to think of one as being in charge of the other. Your web application and web pages should use them and control them as needed.</p><p>Let’s further tie all this together by looking at Redux Middleware and how it can be used to both implement the models above as well as augment our understanding of them via the introduction of well-known Redux concepts or abstractions. While some of these details are implementation and technology specific, they are worth exploring in our context for two reasons. First, Redux is extremely popular, especially as a “pattern,” so there’s value in knowing how to implement something in Redux. Second, and more importantly, Redux’s core concepts involving actions, state, and data flow can help organize and clarify the browser-server models above.</p><p>Let’s start with a brief elaboration of Redux Middleware, so that we can see how it might be used to implement both HTTP and WebSockets. Following the pattern outlined<a href="https://www.metaltoad.com/blog/overview-redux-middleware-react-applications"> here</a>:</p><ol><li>An event occurs</li><li>An action is dispatched</li><li><strong>Middleware receives the action</strong></li><li>Reducer creates a new state from the change prescribed by the action</li><li>New state is passed into the (React, Angular, Vue etc.) app via props</li></ol><p>We see that middleware is code that sits in the “middle.” It receives actions before they are passed to reducers. I now want to show that these core Redux abstractions — actions, reducers, events, and state (which can ultimately be traced back to <a href="https://facebook.github.io/flux/">Flux</a>) — can add value to the mental models we’ve put forward above. Applied to our context, we can think of browser-server communication as a response to some abstract event or action that leads to a new state. So how does this apply to HTTP and WebSockets?</p><p>HTTP communication in redux is typically managed by a library like redux-thunk, redux-saga, or redux-observables. What matters for our purposes is that such libraries manage the request-response cycle. After some event and/or action occurs, a particular request is issued and, based on the response, application state is updated. If an error occurs it is also handled here. Overall, library code is used to manage this request-response cycle such that the application only needs to fire off events, actions, or signals to initiate outbound communication and only needs to respond to state updates to handle inbound communication. It does not need to think about the three key aspects outlined above: starting and stopping such communication, the content of the messages exchanged, or error-handling. This is the value that Redux Middleware adds at the implementation level.</p><p>Let’s now see how Redux Middleware helps with implementing and understanding WebSockets. By using a library, in our case, redux-websocket from GiantMachines, the details of WebSocket communication in the browser is abstracted from most of the rest of the web application. There are a couple of differences from WebSockets and HTTP worth pointing out here both because details matter and because they help solidify the mental models suggested here. First, starting or connecting to a websocket occurs one time as opposed to occurring every time a request is made. This makes the middleware abstraction even more valuable when it comes to websockets as it gives us a place to think about the persistent nature of their long-standing connection. Once we have established the connection, barring interruption, it is always available to both send and receive messages. Second, messages can be received from the server without any user initiation; in fact, messages from the server are best thought of as actions or events. These messages can then be used to update application state depending on their type and contents. Lastly, even an interruption and the corresponding reconnection can be thought of as events and actions. When an interruption event occurs, I need to dispatch an action to reconnect and “catch-up” or recover any messages that were missed.</p><h3>Conclusion</h3><p>In sum, I’ve presented the evolution of my single, HTTP track browser-server mental model to a dual-track model that includes a track for WebSocket communication. I’ve suggested that one set of concepts for understanding both models focuses on: how communication starts and stops, the message content of the communication, and the ways this communication can go wrong (errors). I’ve also suggested organizing one’s implementation and abstractions for browser-server communication using Redux Middleware. In this model, one’s primary application code interfaces with HTTP and WebSocket communication through the middleware abstraction. One’s middleware receives events or actions from the primary application code and handles the details of sending and receiving communication to the server as well as appropriately bubbling up any error conditions. Hopefully, I’ve put forward the right concepts, in the right way, for you to construct, verify, or refine your browser-server mental model. If not, perhaps you can comment and help me in refining mine.</p><p><strong>Further Reading:</strong></p><p>For more details on Redux and WebSocket usage together see:</p><ol><li>The GiantMachines Redux WebSocket Middleware Library we use: <a href="https://github.com/giantmachines/redux-websocket">https://github.com/giantmachines/redux-websocket</a></li><li>A simple example of a Chat application using websockets via Redux: <a href="https://github.com/flaviocopes/chat-app-react-redux-saga-websockets">https://github.com/flaviocopes/chat-app-react-redux-saga-websockets</a></li><li>A two part discussion of concrete options for implementing Websockets as Redux Middleware:<br>- as custom Middleware: <a href="https://www.youfoundron.com/blog/websockets-in-redux-two-approaches/">https://www.youfoundron.com/blog/websockets-in-redux-two-approaches/</a><br>- with Redux Sagas: <a href="https://www.youfoundron.com/blog/websockets-in-redux-using-sagas/">https://www.youfoundron.com/blog/websockets-in-redux-using-sagas/</a></li><li>Another example of using Redux and Redux Saga together: <a href="https://medium.com/@pierremaoui/using-websockets-with-redux-sagas-a2bf26467cab">https://medium.com/@pierremaoui/using-websockets-with-redux-sagas-a2bf26467cab</a></li></ol><p>For more information on some of the key elements in the tech stack mentioned see:</p><ol><li>Django channels<a href="https://channels.readthedocs.io/en/latest/"> https://channels.readthedocs.io/en/latest/</a></li><li>Redux Saga:<a href="https://github.com/redux-saga/redux-saga"> https://github.com/redux-saga/redux-saga</a></li><li>Redux Official Site:<a href="https://redux.js.org/"> https://redux.js.org/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e0747dfbb7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/remesh/establishing-a-long-term-connection-with-websockets-a-story-about-the-ongoing-evolution-of-my-1e0747dfbb7e">Establishing a long-term connection with websockets: a story about the (ongoing) evolution of my…</a> was originally published in <a href="https://medium.com/remesh">Remesh Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>