{"id":1867,"date":"2024-12-23T12:20:13","date_gmt":"2024-12-23T04:20:13","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=1867"},"modified":"2024-12-23T12:20:15","modified_gmt":"2024-12-23T04:20:15","slug":"week-10-internship-solve-signal-r-function-synchronization-pages","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/","title":{"rendered":"Week 10 Internship : Solve Signal R Function &#038; Synchronization Pages"},"content":{"rendered":"\n<h2>Solve Signal R function <\/h2>\n\n\n\n<p>In the first three days, I worked on connecting SignalR to receive the progress count from the item API. Since connecting to SignalR was new to me, I initially faced several challenges. First, I struggled with determining the correct URL to send to SignalR for establishing the connection. Despite trying various URLs, I couldn\u2019t connect successfully. Finally, I sought help from Mr. Peter, who provided me with the correct URL. However, even after using the correct URL, SignalR still showed an unsuccessful connection.<\/p>\n\n\n\n<p>After debugging, researching, and consulting ChatGPT, I discovered the second issue: the HTTP transport type needed to be explicitly initialized. By default, SignalR uses WebSocket as the transport type, which didn\u2019t work for this connection. Switching to long polling as the transport type resolved this issue, and the connection was established. However, a third problem soon arose.<\/p>\n\n\n\n<p>While fetching the sync progress, I noticed it always got stuck at 120\/240 and stopped. After reviewing the log reports, Mr. Peter explained that the syncing process needed to be completed before fetching all item data. Some items were stored and appeared in the database, while others located in stores did not appear in the MongoDB database. This mismatch caused errors. By creating a sync function, I was able to synchronize the items successfully and fetch progress without issues.<\/p>\n\n\n\n<p>Next, I developed a function to cancel the sync progress. This function stops the sync process for an item that hasn\u2019t finished syncing by calling the stop API and passing the GUID, which halts the sync automatically. However, I encountered another issue: the cancel button didn\u2019t work as expected. Initially, I suspected the API, but debugging revealed that the function was rendered twice, causing the cancel function to be invoked twice. As a result, pressing cancel stopped one progress instance, but the other continued syncing. This behavior was due to the Next.js configuration, which caused the\u00a0<code>useEffect<\/code>\u00a0hook to render twice. After adjusting the Next.js configuration, all SignalR-related functions and sync item processes were finalized successfully.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Solve Signal R function In the first three days, I worked on connecting SignalR to receive the progress count from the item API. Since connecting to SignalR was new to me, I initially faced several challenges. First, I struggled with determining the correct URL to send to SignalR for establishing the connection. Despite trying various &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Week 10 Internship : Solve Signal R Function &#038; Synchronization Pages&#8221;<\/span><\/a><\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Week 10 Internship : Solve Signal R Function &amp; Synchronization Pages | Tong Hin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Week 10 Internship : Solve Signal R Function &amp; Synchronization Pages | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Solve Signal R function In the first three days, I worked on connecting SignalR to receive the progress count from the item API. Since connecting to SignalR was new to me, I initially faced several challenges. First, I struggled with determining the correct URL to send to SignalR for establishing the connection. Despite trying various &hellip; Continue reading &quot;Week 10 Internship : Solve Signal R Function &#038; Synchronization Pages&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-23T04:20:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-23T04:20:15+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\",\"name\":\"Week 10 Internship : Solve Signal R Function & Synchronization Pages | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2024-12-23T04:20:13+00:00\",\"dateModified\":\"2024-12-23T04:20:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/\",\"name\":\"Week 10 Internship : Solve Signal R Function &#038; Synchronization Pages\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/82e50d07ae9805ba50acb9b2b3e62388\"},\"headline\":\"Week 10 Internship : Solve Signal R Function &#038; Synchronization Pages\",\"datePublished\":\"2024-12-23T04:20:13+00:00\",\"dateModified\":\"2024-12-23T04:20:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2024\/12\/23\/week-10-internship-solve-signal-r-function-synchronization-pages\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/82e50d07ae9805ba50acb9b2b3e62388\",\"name\":\"Lit Jay Ong\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7e09b4361520d9e5e18a15b258eaf241?s=96&d=mm&r=g\",\"caption\":\"Lit Jay Ong\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1867"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=1867"}],"version-history":[{"count":3,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1867\/revisions"}],"predecessor-version":[{"id":1884,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1867\/revisions\/1884"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=1867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=1867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=1867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}